📜  如何访问 promise 的返回值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:08.307000             🧑  作者: Mango

代码示例1
const address = fetch("https://jsonplaceholder.typicode.com/users/1")
  .then((response) => response.json())
  .then((user) => {
    return user.address;
  });

const printAddress = async () => {
  const a = await address;
  console.log(a);
};

printAddress();