I was trying this
//...
const getMetadata = async () => {
try {
let response = await fetch(
'https://favradio-stats.glitch.me/metadata'
);
let json = await response.json();
return json;
} catch (error) {
console.error(error);
}
};
console.log(getMetadata);
//...
returns [Function getMetadata]
if I call getMetadata()
instead of getMetadata
, will get the undesired result:
{"_U": 0, "_V": 0, "_W": null, "_X": null}
Why and what is wrong with that code?
question from:https://stackoverflow.com/questions/65643472/how-do-i-fetch-json-in-react-native