repl.it
@Kognise/

DisneyPlus

Nodejs

No description

fork
loading
Files
  • index.js
  • Packager files
  • package-lock.json
  • package.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fetch = require('node-fetch')

const search = async (query) => {
  const searchData = {
    preferredLanguage: [ 'en' ],
    index: 'disney_global',
    q: query,
    contentTransactionId: '43c39016-f808-49d6-b55a-fe910636adb1' // What is this?
  }

  const url = [
    'https://search-api-disney.svcs.dssott.com/svc/search/v2/graphql/persisted/query/core/disneysearch',
    `?variables=${encodeURIComponent(JSON.stringify(searchData))}`
  ].join('')

  const res = await fetch(url, {
    headers: {
      'Authorization': `Bearer ${process.env.DISNEY_PLUS_TOKEN}`
    }
  })
  const json = await res.json()

  return json.data.disneysearch.hits.map(({ hit }) => hit)
}

search('james and the giant peach')
  .then(console.log)
Fetching token
?