2017-04-08 57 views
0

我在控制器做this.get('model').save(),并出现以下错误:灰烬JSON API无法识别ID在API响应

Your users record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.

我的串行看起来是这样的: 应用程序/串行器/ application.js中

import DS from 'ember-data'; 
export default DS.JSONAPISerializer.extend({ 
}); 

我的API的回应是:

{ 
    "data": 
    { 
    "id":"20", 
    "type":"users", 
    "attributes": 
    { 
     "first-name":"Lalit", 
     "last-name":"Indoria", 
     "email":"[email protected]", 
     "created-at":"2017-04-08T17:18:02Z", 
     "updated-at":"2017-04-08T17:18:02Z" 
    } 
    } 
} 

我在做什么错?

回答

3

我意识到我在为我的模型使用复数名称。我的模特是app/models/users.js,但它实际上应该是app/models/user.js

+0

如果你能接受这个答案,它也会帮助其他人 –