I just wanted to get random user data from some API then i used async function so that at last i can return person name array. Here is my code
const getPersonName = async () => {
// Fake user Data api
const response = await fetch("https://dummyjson.com/users");
const data = await response.json();
const firstName = data.users.map((currUser) => currUser.firstName);
const lastName = data.users.map((currUser) => currUser.lastName);
return [...firstName, ...lastName];
};
after creating the function i have to store the returning value into names variable then i tried this.
const names = async () => await getPersonName();
when i console.log(names) it is still giving me promise
i wanted to store like this
const names = ['Some name','some name']