how to get value from a fulfilled promise in react

I have an API that return my expected results in a react project.

I wrote this function to call API and get the results:

async function getUsers() {
  const token = store.getState().token;
  const data = { token };
  await MyApi.getUsers(data)
    .then((result) => {
      return result;
    .catch((error) => {
      return null;

const userList = getUsers();

When I console.log the result in the then section of the function, it printed the expected list of users (that is a json array).
But when I console.log the userList it is a promise like bellow image:

enter image description here

that means the returned value of getUsers function is a Promise.

1- How can I get the results from this promise?

2- why the PromiseResult is undefined while the result in then section is a json array?

** these codes are not in the react component

the expected result is:

  id: 1,
  name: "user1",
  role: "student"
  id: 2,
  name: "user2",
  role: "student"
  id: 3,
  name: "user3",
  role: "student"

and I want to use userList array to create user card:

{userList ? ( =>
    <h1> </h1>
(<h1>user list is empty </h1>)

132 thoughts on “how to get value from a fulfilled promise in react”

  1. [url=]sildenafil 90mg[/url] [url=]order viagra online us pharmacy[/url] [url=]cialis online prescription uk[/url] [url=]viagra 500[/url] [url=]sildenafil india brand name[/url] [url=]cheap cialis super active[/url]

  2. [url=]best price cialis 10mg[/url] [url=]modafinil cheap uk[/url] [url=]non prescription viagra[/url] [url=]tadalafil 20 mg price canada[/url] [url=]buy clindamycin online cheap[/url]

  3. [url=]sildenafil 20 mg price comparison[/url] [url=]buy tadalafil paypal[/url] [url=]cialis prescription usa[/url] [url=]sildenafil 20 mg tablets price[/url] [url=]tadalafil where to buy[/url] [url=]tadalafil tablet buy online india[/url] [url=]otc viagra 2018[/url] [url=]american pharmacy[/url] [url=]cialis 5mg best price australia[/url] [url=]ivermectin price uk[/url]

  4. [url=]sildenafil price comparison in india[/url] [url=]viagra price malaysia[/url] [url=]buy viagra 100 mg online[/url] [url=]buy clomid online uk[/url] [url=]price of sildenafil 100mg[/url] [url=]ivermectin 250ml[/url] [url=]ivermectin 8000 mcg[/url] [url=]stromectol pills[/url] [url=]how can you get viagra online[/url] [url=]accutane 40mg capsule[/url]

  5. [url=]purchase viagra canadian pharmacy[/url] [url=]buy sildenafil without prescription[/url] [url=]levitra 20 online[/url] [url=]online pharmacy viagra india[/url] [url=]cost of amoxil[/url] [url=]purchase viagra in mexico[/url] [url=]fluoxetine india[/url] [url=]purchase stromectol online[/url] [url=]ivermectin 6mg tablet for lice[/url] [url=]where to get cialis in singapore[/url]

  6. [url=]sildenafil tablets australia[/url] [url=]order stromectol[/url] [url=]accutane cost[/url] [url=]cheapest tadalafil prices[/url] [url=]where to get viagra[/url] [url=]how much is generic viagra in mexico[/url] [url=]buy cheap generic viagra online[/url] [url=]generic tadalafil from india[/url]


Leave a Comment