0
我工作的一個應用程序,我需要一個字符串數組傳遞到後端服務類似轉換對象數組轉換成字符串
const ids = [];
for (let i = 0; i < pIds.length; i++) {
ids.push(pIds[i].id);
}
// pIds is an array of objects [{id: 2, name: 'dd'}]
this.webClient = new Frisbee({
baseURI: `${Secrets.url_host}/api/v1`,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
});
getData({ continuation = 1, q = '', ids = '' }) {
return this.webClient.get('/whatever', {
body: {
'platform_ids': ids,
},
}).then(getContent);
}
的陣列運行此代碼後,如果得到的id [2,3]例如
但是當我將它傳遞到後端(在軌道上紅寶石)它到達像
[{"0"=>"1", "1"=>"2"}]
的陣列
我能做些什麼來獲得它[[1],「2」]?我試過很多解決方案,但沒有任何工作。
你能告訴你哪裏調用你的函數傳遞值的代碼? –
您可能會發送pIds而不是ID –
否我發送ids, –