需要将数据对象作为第二个参数传递给post方法。例如:
const data = { name: 'John', age: 30 };
axios.post('/api/users', data)
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
});
在上面的示例中,数据对象(即{ name: 'John', age: 30 })作为第二个参数传递给了post方法。这样,Axios就会将整个数据对象作为请求主体发送到服务器。