I have set up axios to make requests to my express backend hosted on localhost:8081
src/htpp/index.js
import axios from 'axios'
export default axios.create({
baseURL: 'http://localhost:8081/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
})
In a vue component, I utilize this setup to send a post request with form data
src/components/create-list.vue
import http from '../http'
http.request({
url: 'lists',
method: 'post',
data: {
displayName: this.displayName,
listName: this.listName,
userEmail: this.userEmail
}
})
However, upon form submission, the following unexpected request is made:
Request URL: http://localhost:8080/?list-name=Test&user-email=test%40test.de&user-name=Test
Expected Request URL : http://localhost:8081/api/lists
Expected Request Method : POST
Expected Request body : {"list-name": "Test", "user-email": "[email protected]", "user-name": "Test"}
Can someone help identify what is wrong in this situation?