When I execute the following code from my browser, the server gives me 400 and complains that the request body is missing. Has anyone understood how I can pass a simple string and send it as the request body?
let content = 'Hello world'
axios.put(url, content).then(response => {
resolve(response.data.content)
}, response => {
this.handleEditError(response)
})
If I complete the content in [], it will get through. But then the server receives it as a line starting with [and ending]. Which seems strange.
After scrolling, I found that the following works
let req = {
url,
method: 'PUT',
data: content
}
axios(req).then(response => {
resolve(response.data.content)
}, response => {
this.handleEditError(response)
})
But shouldn't the first work?
source
share