D
D
drawnofmymind2020-03-15 07:26:57
local server
drawnofmymind, 2020-03-15 07:26:57

vue-cli. axios not seeing json file?

The code:

async created(){
      try {
       const response =  await axios.get("/proj/public/server/data.json")
       console.log(response)
      } catch (error) {
         console.log(error)
      }
}

Error: GET localhost:8080/proj/public/server/data.json 404 (Not Found)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Taktan Stepanov, 2020-05-14
@Taktan

Need to import json file

const data = require("/proj/public/server/data.json");
async created(){
      try {
       const response =  await axios.get(data)
       console.log(response)
      } catch (error) {
         console.log(error)
      }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question