I'm looking to practice simulating API calls for a VueJS application. Currently, I am fetching data from a hardcoded JSON file that I've created.
Within my App.vue
:
<template>
<p>{{ teams.yankees.city }}</p> // Output will be "New York"
</template>
<script>
import teams from './teams.json'
export default {
data() {
return { teams }
}
}
</script>
In my teams.json
file:
{
"yankees": [
{ "city": "New York", "established": 1901, "worldSeries": 27 }
]
...
}
Although I can currently retrieve data from the local JSON file, I am interested in implementing "function stubs" to prepare for integrating real restful API calls in the future.
Is there a straightforward guide available that demonstrates how to set up a mock rest service to fetch data from my local JSON file?