Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to access return value of promise

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();
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #How #access #return #promise
ADD COMMENT
Topic
Name
8+5 =