mardi 1 mai 2018

404 When Consuming Dark Sky Weather API with Ember

Any idea why I'm getting a 404 when I try to make a GET request to Dark Sky? https://darksky.net/dev/docs

Error:

jquery.js:9600 GET https://api.darksky.net/forecast?key=secretString&latitude=42.361145&longitude=-71.057083&time=1525213510 404 (Not Found)

Here's my model:

import DS from 'ember-data';

export default DS.Model.extend({
  temperature: ('number'),
  summary: DS.attr('string'),
  icon: DS.attr('string')
});

Here's my route (I've also tried to keep lat and long in string format):

import Route from '@ember/routing/route';

export default Route.extend({
  model () {
    let currentTime = Math.round(new Date()/1000);
    return this.store.query('weather', { key: "secret_string", latitude: 42.361145, longitude: -71.057083, time: currentTime} );
  }
});

Here's my adapter:

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  host: "https://api.darksky.net",

  pathForType() {
    return 'forecast';
  }
});

And here's my serializer:

import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  normalizeResponse(store, primaryModelClass, payload, id, requestType) {
    payload = { weather: payload };
    return this._super(store, primaryModelClass, payload, id, requestType);
  }
});




Aucun commentaire:

Enregistrer un commentaire