'response is working but result is undefined
I have a simple POST request using fetch()
fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: '[email protected]', password: 'test' }),
})
.then((response) => {
response.json();
})
.then((result) => {
console.log(result);
});
the response is valid and gives the JSON that I am expecting { 'id':1 } but the result just returns undefined every time. Have I written something incorrectly or am I missing something really simple?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
