2016-05-10 63 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

相關問題