0

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?

1
  • I don't think there are common ways. If you want to avoid extra calls, the obvious way is to cache responses or even mock them with static data. Commented Jan 20, 2022 at 19:40

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.