dimanche 14 février 2021

EmberJs: How to resolve Promise Many Array?

i'm really new on Ember and still figuring things out. So i'm sorry for the beginner question.

Hi have a one-to-many relation in my models like:

import Model, { attr, hasMany } from '@ember-data/model';

export default class EventModel extends Model {
  @attr field_1;
  @attr field_2;
  @attr field_n;

  @hasMany('comment') comments;
}

and

import Model, { attr, belongsTo } from '@ember-data/model';

export default class CommentModel extends Model {
  @attr field_1;
  @attr field_2;
  @attr field_n;

  @belongsTo('event') event;
}

The classic "An article has many comments thing"...

Everything goes well on my template when I'm getting Event data, but when I try to get its related comments, Ember gives me a Promise: <DS.PromiseManyArray:ember219>

All my attemps on resolve the promise failed. How can I resolve that?




Aucun commentaire:

Enregistrer un commentaire