0

I'm having an error that's blowing my mind. I'm trying to mock some data in order to test my app developed with Vuex + Axios.

So...

Having these JSON files at my project's folder:

enter image description here

And this AJAX method:

function fetchChartsData(platform, content) {

    const url = `server/chartsCollection?platform=${platform}&content=${content}.json`;

    axios
        .get(url)
        .then(response => (console.log(response.data)))
        .catch(error => console.error('fails:', error));

}

I'm getting a JSON file with:

  • The correct route name
  • BUT The data/content from another file

For example, the file name at Network is correct:

enter image description here

But the content is from another file:

enter image description here

It's hard to explain. There is no pattern to check with which file is changing the content. I've disabled cached as well.

Thank you!

UPDATE

If I store each file at an isolated folder... it works. I mean:

Mocked server folder:

enter image description here

New code:

function fetchChartsData(platform, content) {

    const url = `server/${platform}/chartsCollection?platform=${platform}&content=${content}.json`;

    axios
        .get(url)
        .then(response => (console.log(response.data)))
        .catch(error => console.error('fails:', error));

}

It's fine that it works... but I'd need to have all files at the same folder to simulate the real backend environment.

SazLamas
  • 45
  • 8
  • Can you inspect the url value being passed (like doing a `console.log(url)`) prior to calling the `axios.get` method? Does the URL align with the files and the data being retrieved? – Angelo Nov 19 '19 at 16:36
  • Yes, the URL is completely correct and the AJAX call responds with a 200. But, when you open the Network window at browser: - It loads the correct name/url file - The content of that file is not correct (checking it at network/preview) I'll upload some screenshots to the question. Thank you – SazLamas Nov 19 '19 at 17:05

0 Answers0