0

I have this code. I am using the fetch-jsonp library in my React-Redux app.

export function fetchAirBnbData() {
  return function (dispatch) {
    fetchJsonp('http://assets.airbnb.com/frontend/search_results.js', {
     jsonpCallback: 'search_results',
   })
      .then(function (response) {
        console.log(response)
        return response.json()
      }).then(function (json) {
       console.log('parsed json', json)
       dispatch(loadAirBnBData(json))
      }).catch(function (ex) {
       console.log('parsing failed', ex)
     })
 }
}

I am getting this error

Uncaught ReferenceError: search_results is not defined

From what I know, this should work. Any ideas what is happening here?

developarvin
  • 4,940
  • 12
  • 54
  • 100

1 Answers1

0

I'm the author of fetch-jsonp, you should use

fetchJsonp('http://assets.airbnb.com/frontend/search_results.js', {
  jsonpCallbackFunction: 'search_results',
})
Cam Song
  • 2,956
  • 1
  • 22
  • 18