then pass the formData instead of userInfo to the api request
check that the register is working by going to the users tap
Login
Open Login.js component in the pages folder.
import the login found in the api/auth.js Use the useMutation hook with the login function and pass it the user info.
you should see the token in the response
Maintaining Login (Local storage)
In auth.js file create a function setUser that saves your token in the localStorage
In your api/index.js, use your instance to create an interceptor using the interceptors.request.use() method with an anonymous function. We will check if the response has a property called token. Save the the data with to a variable called token. Save the token using localStorage.setItem with the key token and the value token
Logout
go to auth.js in the api folder
create a function logout that resets the user to null and deletes the token from the instance header.
Sending requests with the auth token attached
Protected Routes (aka cant add a new pet if not logged in ‘if going to use the pet api’)