我是post
一个Axios请求,因为使用get
会导致414错误。这是对象:
rows= {
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+个元素,因此是post
而不是get
。我在此上正确构建表单数据时遇到麻烦。这是我所拥有的:
let data = new FormData();
Object.keys(rows).forEach(key => data.append(key, rows[key])); // <--- this doesn't do
data.set('target', target); // <---- this comes through just fine
axios({
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);
}
});
只是[Object][Object]' when i
var_dump($ _ POST);`。这不是我想要的。我该如何正确地重写它,以便将数据传输到另一端(例如GET ...)。
Are for inserting new stuff, instead of doing a post you need a patch
axios.patch it is basically the same. And it won’t fix your issue.
To fix the issue you need to set the
Content-Type`到application / json,然后是yow