Function
const GetProfile = async (username) => {
await fetch(`${host}/api/v1/getprofile/${username}`).then((resp) => {
console.log(resp.json());
});
};
Why am i getting Promise { <state>: "pending" } on calling function like this GetProfile("username");
What should i do?
Thanks in Advance!
>Solution :
Since you are in an async function, a clean way to do this is :
const GetProfile = async (username) => {
const res = await fetch(`${host}/api/v1/getprofile/${username}`);
const data = await res.json();
return data;
});
};