JS Fetch API access return value [duplicate]
问题 This question already has answers here : How do I return the response from an asynchronous call? (42 answers) Closed 2 years ago . This is how I access the result from a fetch call: let data; fetch(someUri) .then((response) => response.json()) .then(_data => { data = _data; }) .catch(error => { console.error(error); }); Is it also possible to access the result from the fetch function itself, like this: let data = fetch(someUri) .then((response) => response.json()) .then(data => { // do some