I’ve got an unusual problem. On my backend I have an express.js API feeding ember data. Right after I add a new record to the database (I’m running mongo), and then go to the index page which fetches all records I’ll get duplicate records. When I refresh, the duplicate disappears. It only happens some times, and I’m not sure whats casing it. I checked my backend, and it’s only sending any duplicate information.
I’ve attached link to an image that better illustrates the issue.
It’s hard to say precisely what’s happening without seeing the code. How are you fetching the data in the model hook? What does the save action look like for adding a new record?
export default Ember.Route.extend({
model() {
return this.store.createRecord('library');
},
actions: {
//where newLibrary is the model we passed in from the template
saveLibrary(newLibrary) {
newLibrary.save().then(() => this.transitionTo('libraries.index'));
},
willTransition() {
this.controller.get('model').rollbackAttributes();
}
}
});
displaying the libraries:
export default Ember.Route.extend({
model() {
return this.store.findAll('library');
},
actions: {
//where library is the model passed in from the template
deleteLibrary(library) {
let confirmation = confirm('Are you sure?');
if (confirmation) {
library.destoryRecord();
}
}
}
});
the api controller sending the data (I’m transpiling with babel for es6 functionality):