So I was trying to bring out a variable named data that's storing the value 42 from a .then() method from the following code which console logs 42:
fetch("http://localhost:8088/get/value")
.then(response => response.json())
.then(data => console.log(data));
I was told I wouldn't be able to do that and that I should try await/async so I readjusted my code to:
asyncCall();
async function asyncCall()
{
var a = await fetch("http://localhost:8088/get/value");
console.log(a);
}
and it ends up console logging the whole response but weirdly it registers false for whether the body is used or not when I thought that the value 42 was sent through the body. Why did the value 42 seemingly disappear when before I was logging it fine? -And what can I do so that it console logs the original value 42 with async/await? Thanks for the future help.