current position:Home>Vue3 uses Axios to request JSON files in the public folder, and there is always a 500 error!

Vue3 uses Axios to request JSON files in the public folder, and there is always a 500 error!

2022-02-02 19:41:13 CSDN Q & A

Problems encountered :

img

pubilc Under folder data.json file :

img

vue.config.js Configuration of :

img

axios To configure :

img

Manually entering the address can display data.json Contents of Li :

img




Refer to the answer 1:

target Change it http://localhost:8080




Refer to the answer 2:



Refer to the answer 3:
 You need to import before you can use let all = require('./json/a.json');



Refer to the answer 4:



Refer to the answer 5:

Get rid of ‘/api’, There is no need to configure the agent

img




Refer to the answer 6:



Refer to the answer 7:

img


There is no treatment here , Then the data is a locally created json data , No treatment , So when we call the interface, we can directly request , There is no need to transfer values




Refer to the answer 8:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021941116952.html

Random recommended