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) => {
      console.log(result);
      return result;
    })
    .catch((error) => {
      console.log(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:

<div>
{userList ? (
 userList.map((user) =>
 {
  <Card>
    <h1> user.name </h1>
  </Card>
 }
):
(<h1>user list is empty </h1>)
}

1,481 thoughts on “how to get value from a fulfilled promise in react”

  1. [url=http://viagraefc.com/]sildenafil 90mg[/url] [url=http://orderviagratabs.com/]order viagra online us pharmacy[/url] [url=http://ngcialis.com/]cialis online prescription uk[/url] [url=http://viagradmed.com/]viagra 500[/url] [url=http://buyingsildenafil.com/]sildenafil india brand name[/url] [url=http://ppcialis.com/]cheap cialis super active[/url]

    Reply
  2. [url=https://buycialist.com/]best price cialis 10mg[/url] [url=https://modafinilxc.com/]modafinil cheap uk[/url] [url=https://hotviagraonline.com/]non prescription viagra[/url] [url=https://buytadalafilpills.com/]tadalafil 20 mg price canada[/url] [url=https://cleocinmed.com/]buy clindamycin online cheap[/url]

    Reply
  3. [url=https://sildenafilsale.com/]sildenafil 20 mg price comparison[/url] [url=https://norxtadalafil.com/]buy tadalafil paypal[/url] [url=https://ppcialis.com/]cialis prescription usa[/url] [url=https://sildenafilgenericpills.com/]sildenafil 20 mg tablets price[/url] [url=https://gettadalafil.com/]tadalafil where to buy[/url] [url=https://tadalafilvpill.com/]tadalafil tablet buy online india[/url] [url=https://viagrapns.com/]otc viagra 2018[/url] [url=https://pharmacysx.com/]american pharmacy[/url] [url=https://cialisfv.com/]cialis 5mg best price australia[/url] [url=https://ivermectinpillscv.com/]ivermectin price uk[/url]

    Reply
  4. [url=http://viagracpill.com/]sildenafil price comparison in india[/url] [url=http://sildenafilpharm.com/]viagra price malaysia[/url] [url=http://viagrahtab.com/]buy viagra 100 mg online[/url] [url=http://buyrxtablets.com/]buy clomid online uk[/url] [url=http://buysildenafilpills.com/]price of sildenafil 100mg[/url] [url=http://ivermectinpn.com/]ivermectin 250ml[/url] [url=http://opivermectin.com/]ivermectin 8000 mcg[/url] [url=http://ivermectinzt.com/]stromectol pills[/url] [url=http://viagrawithnoprescription.com/]how can you get viagra online[/url] [url=http://xrpills.com/]accutane 40mg capsule[/url]

    Reply
  5. [url=http://sildenafilvtab.com/]purchase viagra canadian pharmacy[/url] [url=http://buysildenafilpills.com/]buy sildenafil without prescription[/url] [url=http://medptr.com/]levitra 20 online[/url] [url=http://sildenafilpharm.com/]online pharmacy viagra india[/url] [url=http://rxremi.com/]cost of amoxil[/url] [url=http://viagrabuycheap.com/]purchase viagra in mexico[/url] [url=http://crmeds.com/]fluoxetine india[/url] [url=http://ivermectinpn.com/]purchase stromectol online[/url] [url=http://ivermectinop.com/]ivermectin 6mg tablet for lice[/url] [url=http://anycialis.com/]where to get cialis in singapore[/url]

    Reply
  6. [url=http://sildenafilchem.com/]sildenafil tablets australia[/url] [url=http://opivermectin.com/]order stromectol[/url] [url=http://xrpills.com/]accutane cost[/url] [url=http://tadalafilbestbuy.com/]cheapest tadalafil prices[/url] [url=http://viagraconn.com/]where to get viagra[/url] [url=http://anviagra.com/]how much is generic viagra in mexico[/url] [url=http://xviagrahot.com/]buy cheap generic viagra online[/url] [url=http://tadalafilmtab.com/]generic tadalafil from india[/url]

    Reply
  7. Hey there! This post couldn’t be written any better! Reading through this post reminds me of my old room mate! He always kept chatting about this. I will forward this post to him. Pretty sure he will have a good read. Thanks for sharing!

    Reply
  8. I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an impatience over that you wish be delivering the
    following. unwell unquestionably come further formerly again since exactly the same nearly a lot often inside
    case you shield this hike. http://antiibioticsland.com/Flagyl_ER.htm

    Reply