Aurelia: fetch-client response doesn't have my data -
i've been banging head against fetch-client long , need help.
i'm getting data skyscanner. request hits api , chrome's dev tools list in network tab complete fetch request code 200 , correct response body.
import {inject} 'aurelia-framework'; import {httpclient} 'aurelia-fetch-client'; @inject(httpclient) export class flights { constructor(http){ http.configure(config => { config .withbaseurl('http://partners.api.skyscanner.net/apiservices/') .withdefaults({ mode: 'no-cors', headers: { 'accept': 'application/json', 'content-type' : 'application/json' } }); }); this.data = ""; this.http = http; } activate() { this.http.fetch('browsequotes/v1.0/gb/gbp/en-gb/uk/anywhere/anytime/anytime?apikey=myapikeygoeshere') .then(response => { console.log(response); console.log(response.response); console.log(response.content); console.log(response.data); }) .catch(ex => { console.log(ex); }); } }
but when response object printed has nothing in it:
response {} body: null bodyused: false headers: headers __proto__: headers ok: false status: 0 statustext: "" type: "opaque" url: "" __proto__: response
all of remaining console.log's produce undefined
am using fetch-client incorrectly? missing?
notice you're receiving opaque response (type: "opaque"
). opaque responses not allow read them. due no-cors
mode set before. should use cors
mode , skyscanner should provide proper headers api key think they don't do.
Comments
Post a Comment