DEV Community

Discussion on: Axios PUT Verb

Collapse
 
tqbit profile image
tq-bit

I feel you. You might not believe it, but I ran into pretty much the same fail today as well (token somehow ended up in the data - prop, wtf was I thinking)

My lesson learned here (hopefully) was:

  • Create axios instances in separate files and export them.
  • Explicitly define headers, http-method and data in a config object
// ... some async function code
const config = {
 url: 'https://my-url.com', 
 method: 'get',
 headers: {/* ... */},
 data: JSON.stringify({/* ... */})
}

const response = await axios(config)
// ... some more function code
Enter fullscreen mode Exit fullscreen mode