Fetch API Using Async/Await Return Value Unexpected [duplicate]
问题 This question already has an answer here : js async/await return promise (1 answer) Closed last year . Here's the function: const getUserIP = async () => { let response = await fetch('https://jsonip.com/'); let json = await response.json(); console.log(json.ip) return json.ip; }; In the console, the IP address is logged as expected. However, when I save the 'IP address' to a variable: const ip = getUserIP(); And then type ip in the console, the value is shown as: Promise { <state>: "fulfilled