I'm trying to consume an API from this URL, which returns a jsonp
I have this code
new Vue({
el: '.App',
mounted: function () {
this.cojerDatos()
},
data: {
losDatos: {}
},
methods: {
cojerDatos() {
const url = "http://opendata.euskadi.eus/contenidos/ds_recursos_turisticos/albergues_de_euskadi/opendata/alojamientos.json";
//let params = {callback: 'jsonCallback'}
this.$http.jsonp(url, {params:{callback : 'jsonCallback'}})
.then(response => console.log(response.data))
},
}
})
but it always returns the following error
I think the error is that the callback that is being returned is generated randomly, instead of returning jsonCallback.
I'm using the vue-resources library, and from what I've read, when the method is jsonp, it generates a script with a callback call by default "callback", if you do not pass any parameters, I'm trying to pass it on, but obviously I'm doing it wrong.
I will appreciate your help.
Greetings.