Quasar Axios request wrong URL (Double URL)

|▌冷眼眸甩不掉的悲伤 提交于 2020-07-20 04:22:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!