jeudi 3 mai 2018

Ember: Error while processing route. Can't hit API

This code works (hardcoded):

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
    model() {
        let stars = [
            {
                key: "johnlennon",
                logoUrl: "https://www.images.com/johnl.png",
                name: "John Lennon",
                alive: false
            }
        }
    }
});

When I do this, it doesn't (from API):

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import config from '../../../../../config/environment';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
    model() {
        const token = this.get('session.data.authenticated.token');
        return Ember.RSVP.hash({
            stars: Ember.$.getJSON(Ember.$.getJSON(`${config.APP.starsAPI}/api/stars?authorizationToken=${token}`))
        });
    }
});

The error I receive:

jquery.js:9175 GET http://localhost:4242/stars/948/connect/[object%20Object] 404 (Not Found)

ember.debug.js:30291 Error while processing route: stars.show.connect.stars.index

As you may have guessed, I need it to work from API. Why is that giving me the error?




Aucun commentaire:

Enregistrer un commentaire