Quasar Axios请求错误的URL(双URL)

编程入门 行业动态 更新时间:2024-10-28 06:25:19
本文介绍了Quasar Axios请求错误的URL(双URL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

错误图片

当我通过带有URL的axios发送请求时axios连接api的url 与类星体开发服务器的URL,我怎么能忽略这一点 串联并仅在有任何配置的情况下发送API URL axios与类星体的baseUrl?

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/启动 从"axios"导入axios

src/boot import axios from 'axios'

export default async ({ Vue }) => { axios.defaults.baseURL = 'http//:localhost:3000/' Vue.prototype.$axios = axios }

组件:

this.$axios({ url : 'backend/spots/all', }).then(response=>{ this.allSlots = response.data })

推荐答案

根据Quasar 文档,您可以尝试以下操作:

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 }

用于某些用途| js文件:

to use in some vue | js file:

import { axiosInstance } from 'src/boot/axios' axiosInstance.get('/some-endpoint')

更多推荐

Quasar Axios请求错误的URL(双URL)

本文发布于:2023-10-11 23:56:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483202.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   Quasar   Axios   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!