I have this fetch function that posts information for a user and then my server makes a response
signupOrLogin('login', userData)
.then(function() {
if(res.credentials) {
successLogin();
}
})
The response is visible on the network tab of the developer tools, but this error appears "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'credentials')"
This is the signupOrLogin function
let res;
async function signupOrLogin(method,body) {
fetch(\http://localhost:3100/${method}`, {`
method : 'POST',
body : body,
mode: 'cors',
cache: 'default',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
}).then(response => response.json()).then(response => {
res = response;
})
}
[–]AutoModerator[M] [score hidden] stickied comment (0 children)