Vue usersvue form practise
10:38 16 May 2026

Title:

Vue 3 fetch works for first request but fails/omits credentials on subsequent API call in onMounted

Body:

I am developing a user management dashboard in Vue 3 using

My questions:

  1. I forgot to include credentials: 'include' in the second fetch("http://localhost:3000/api/users") call. Will this cause the Express backend to reject the request if the routes are protected, or will it just omit the session cookie?

  2. Similar to my other views, calling router.push('/') inside the if (!res.ok) block does not stop the rest of the function from executing. What is the cleanest way to prevent the /api/users fetch from firing at all if the initial session check fails?

Thank you for your help and insights!

vue.js