我有一个简单的Axios POST请求:
const data = JSON.stringify({
to: receiver,
from: sender,
body: message
});
axios.post(window.location.origin + '/sms/outgoing', data)
我的问题是我的api读取请求正文:
{ '{"to":"12345","from":"54321","body":"message"}': '' }
当我想要它时:
{"to":"12345","from":"54321","body":"message"}
我哪里错了?
答案 0 :(得分:1)
JSON.stringify方法不需要..
component.setStarFlag(true, false);
但你需要JSON.stringify方法来跟随这个后端api调用
const data = {
to: receiver,
from: sender,
body: message
};
axios.post(window.location.origin + '/sms/outgoing', data)
答案 1 :(得分:0)
如果要从JSON字符串解析JSON对象,只需使用const object = JSON.parse({
someJSONString: true,
})
函数
{{1}}