Is There A Way To Prevent Vue Hot Reload From Making Too Many API Calls?
I'm new to vue and I just started working on my first project.
In my main component, I have a fetch request to an (limited) API endpoint on page load. Every time I make changes to my code, the page refreshes and makes a new API call.
What are some common ways to avoid overusing network requests when using hot reload?
Answer
There are ways to deal with reducing the api requests, but it depends on the context. Assuming this is only for development though, and you don't want to have any API caching in production, the best way is likely to proxy (or mock if possible) you API.
I usually just setup a custom mock server, so can't guarantee success, but looks like node-api-cache-proxy might be helpful to get an express server to cache your api calls. Then you can setup a proxy in your vue config file to point to the proxy instead of to the API directly
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Get the calling element with vue.js
- → Vue.js - Binding radio elements of same name to array
- → Get data from DB based on selected values. Vue.js + laravel
- → Vuejs IF statement
- → VueJS set Input field data
- → How do I use vue-resource v-links inside a vueify component?
- → Export more than one variable in ES6?
- → How create a todo list with octobercms?
- → Using vue.js in Shopify liquid templates
- → Apply a discount using VueJS and Laravel
- → Laravel 5.2 CORS, GET not working with preflight OPTIONS
- → Vue @click doesn't work on an anchor tag with href present