Answer the question
In order to leave comments, you need to log in
How to set the default API endpoint in Axios, which is a file?
I use Axios to create a SPA on Vue.js
There is a backend with an address like: https://backend.site.com/api.php
Any requests have the following pattern, examples:
https://backend.site.com/api.php?cmd=users
https://backend.site.com/api.php?cmd=goods&limit=20
https://backend.site.com/api.php?cmd=posts&page=2
const webclient = axios.create({
baseURL: "https://backend.site.com"
})
webclient.get("api.php?cmd=users").then ...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question