I am making a flash card app and the business logic is implemented in the backend.
The previous version I use jquery to fetch data and make request between server and client (see below),
getNextCard() {
const {URL, headers} = this._getParams('/next_card');
return Ember.$.ajax(URL, {
method: "GET",
headers
});
},
submitAnswer(card) {
const {URL, headers} = this._getParams('/process_card');
return Ember.$.ajax(URL, {
method: "POST",
headers,
data: card
});
},
Ember.$.ajax
getNextCard
Try to represent this as CRUD operations. It's a bit another way of thinking.
So you could for example set the answer on the record, and then just .save()
the record. Or have another answer
model, and create an answer
and save that. Depends a bit on the specific requirements of your application.
To retrieve the next card just use store.query()
. So that you basically can do something like store.query('card', { next: true })
, and implement this in your adapter accordingly.