亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JS:具有大型嵌套對象和表單數據的 axios POST

JS:具有大型嵌套對象和表單數據的 axios POST

aluckdog 2022-08-27 13:54:20
我是 Axios 請求,因為使用會導致 414 錯誤。這是對象:postgetrows= {  0 : {    "name":"Thor",    "status":"active",    "email":"[email protected]",  },  1 : {    "name":"Mesa",    "status":"active",    "email":"[email protected]",  },  2 : {    "name":"Jesper",    "status":"stdby",    "email":"[email protected],  },}這只是對象格式的一個示例。在實際的一個中有400多個元素,因此而不是。我在正確構建表單數據時遇到了麻煩。以下是我所擁有的:postgetlet data = new FormData();Object.keys(rows).forEach(key => data.append(key, rows[key]));  //  <--- this doesn't dodata.set('target', target);  //  <---- this comes through just fineaxios({  method: 'post',  url: 'byGrabthorsHammer.php',  data: data,  headers: {'Content-Type': 'multipart/form-data'}}).then(function(response) {  if (response.error) {    console.log('failed to send list to target');    console.log(response);  } else {    console.log('response: ');    console.log(response);  }        });通過的只是var_dump($_POST);'。這不是我想要的。我怎么能正確地重寫這個,以便我得到數據到另一邊(如GET...)。[Object][Object]' when i
查看完整描述

2 回答

?
青春有我

TA貢獻1784條經驗 獲得超8個贊

Yow兄弟,是用來插入新的東西,而不是做一個帖子,你需要一個補丁axios.patch它基本上是一樣的。它不會解決您的問題。要解決此問題,您需要將 應用程序/json 設置為,然后在 yow 上POSTContent-Type

axios.post(url, data: JSON.stringify(bigObject))
   .then(Rea=>Rea)


查看完整回答
反對 回復 2022-08-27
?
POPMUISE

TA貢獻1765條經驗 獲得超5個贊

您可以嘗試將數據字符串化。JSON.stringify(data)


查看完整回答
反對 回復 2022-08-27
  • 2 回答
  • 0 關注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號