Closed NavarroHoz closed 3 years ago
Based on what I see when going to http://opendata.euskadi.eus/contenidos/ds_recursos_turisticos/albergues_de_euskadi/opendata/alojamientos.json, it appears that this service is always going to return the callback as jsonCallback
. So the request you want to build is http://opendata.euskadi.eus/contenidos/ds_recursos_turisticos/albergues_de_euskadi/opendata/alojamientos.json?callback=jsonCallback
which means you want to use:
fetchJsonp("http://opendata.euskadi.eus/contenidos/ds_recursos_turisticos/albergues_de_euskadi/opendata/alojamientos.json", {
jsonCallbackFunction: 'jsonCallback'
});
Check out https://github.com/camsong/fetch-jsonp#difference-between-jsonpcallback-and-jsoncallbackfunction for clarification between jsonpCallback
and jsonCallbackFunction
.
jsonpCallbackFunction: 'jsonCallback'
I try to consume an API that returns a function called jsonCallback, I put the following code and return the error
var fetchJsonp = require("fetch-jsonp") fetchJsonp("http://opendata.euskadi.eus/contenidos/ds_recursos_turisticos/albergues_de_euskadi/opendata/alojamientos.json", { jsonpCallback: 'jsonCallback', }) .then(function(response) { return response.json() }).then(function(json) { console.log('parsed json', json) }).catch(function(ex) { console.log('parsing failed', ex) })
If I look in the header of the request, I see that it happens as a parameter a random callback function.
I'm probably doing something wrong,
Some solution or idea.
Thank you