[Solved] How can I configure rest api params (server:port) in my electron app?
-
Hello guys,
I’m struggling with my first electron app.
A button triggers a rest api call:
this.$axios.post(’/api/v1’, …
It fails (Network Error) …
Where do I configure my app to use the real url?:
http://<server>:<port>/api/v1I have had no problems with the spa version.
Thanks
-
Check out the quasar extension dotenv (or the newly released qenv - but I may be mistaken). The way I have this set up is with a dev env and a production env which allows you to use your respective dev or production api.
You can then reference and set your base url in the boot axios file located at
src/boot/axios.js
via:axios.defaults.baseURL = process.env.API;
In my case
process.env.API = "http://localhost:8000/api"
If you’re just looking to set the api url just set
axios.defaults.baseURL
directly -
Thank you mKomo, it works!
I’m just a newbie.