R
R
rsoinvi2019-01-15 16:26:43
Vue.js
rsoinvi, 2019-01-15 16:26:43

How to load local json in vue?

Throws App.vue?234e:47 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
at eval (App.vue?234e:45)
swears at " .then(response => response.json()) "
Checked all the ways

methods:{
    fetchData(){
      let url = '/store/api.json';
      fetch( url, {
        headers : { 
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        }
      })
      .then(response => response.json())
      .then( json => {
        console.log(json)
      });
    }
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Klein Maximus, 2019-01-15
@kleinmaximus

Most likely, you do not have a /store/api.json file on your server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question