2016-05-10 135 views
0

我对api请求使用烬数据框架。有没有办法为单个API请求提供两个有效载荷?烬数据中的单个请求的多个有效载荷

+0

两种不同类型的有效载荷,如用户和权限或两个有效载荷两种用户? – TameBadger

+1

你正在寻找的是[RSVP.hash](http://emberjs.com/api/classes/RSVP.html#method_hash) –

回答

0

使用JSON-API可以包括相关类型,例如参见here

HTTP/1.1 200 OK 
Content-Type: application/vnd.api+json 

{ 
    "data": [{ 
    "type": "articles", 
    "id": "1", 
    "attributes": { 
     "title": "JSON API paints my bikeshed!", 
     "body": "The shortest article. Ever.", 
     "created": "2015-05-22T14:56:29.000Z", 
     "updated": "2015-05-22T14:56:28.000Z" 
    }, 
    "relationships": { 
     "author": { 
     "data": {"id": "42", "type": "people"} 
     } 
    } 
    }], 
    "included": [ 
    { 
     "type": "people", 
     "id": "42", 
     "attributes": { 
     "name": "John", 
     "age": 80, 
     "gender": "male" 
     } 
    } 
    ] 
} 

在这个例子中看到article有关系称为people型,然后将其在相同的有效载荷includedauthor

+0

我的需求是并行地有两个不同的有效载荷。例如。 {payload1:{name:“Myname”},payload2:{age:“Myage”}} –

+0

我不相信包含的对象必须与主体有关系。 – albertjan

相关问题