问题
The Error Image
when i send request via axios with url axios concatenate url of api with the url of the quasar dev server how can i neglect this concatenation and send the API url only there is any configuration for baseUrl of axios with quasar ?
src/boot import axios from 'axios'
export default async ({ Vue }) => {
axios.defaults.baseURL = 'http//:localhost:3000/'
Vue.prototype.$axios = axios
}
the componennt :
this.$axios({
url : 'backend/spots/all',
}).then(response=>{
this.allSlots = response.data
})
回答1:
According Quasar documentation you can try it as below:
// src/boot/axios.js
const axiosInstance = axios.create({
baseURL: 'http//:localhost:3000'
})
export default async ({ Vue }) => {
Vue.prototype.$axios = axiosInstance
...
}
export { axiosInstance }
to use in some vue | js file:
import { axiosInstance } from 'src/boot/axios'
axiosInstance.get('/some-endpoint')
回答2:
I am not sure, but can you try to change axios.defaults.baseURL = 'http//:localhost:3000/'
to axios.defaults.baseURL = 'http://localhost:3000/'
(change colon place) ?
来源:https://stackoverflow.com/questions/58680554/quasar-axios-request-wrong-url-double-url