I'm trying to use fetch to get a JSON object from an API, I want to return the final resolved value of the object so that any one who uses the function can directly get the value without any need to resolve the promise it returns.
function f() {
let result = fetch(url, {
method: 'GET'
})
.then(response => response.json())
.then(json => {
return json
}).catch(err => {
// Error
});
return result;
}
I don't really know if this is possible or not, but I'll be thankful for help, Thanks in advance.