Send “raw” payload to Axios

前端 未结 2 1530
你的背包
你的背包 2021-02-14 15:13

How can I send a raw payload/request body to Axios?

The endpoint I\'m trying to call expects the request body to just be a string which it\'ll scoop up and use.

2条回答
  •  天涯浪人
    2021-02-14 16:00

    It turns out, if I set the Content-Type header to text/plain, it won't convert it to JSON or form data and will send it as I want.

    axios.post('/my-url', 'my message text', {
      headers: { 'Content-Type': 'text/plain' }
    });
    

提交回复
热议问题