0

I want to use class Api component for my react app. It is look like this with method getCards:

getCheck(res: any) {
  return res.ok ? res.json() : new Promise.reject("fail");
}

getCards() {
  const requestOptions:any = {
    method: "GET",
    headers: this.header,
    redirect: "manual"
  };

  return fetch("/oapi/privelege/getAllPrivilege", requestOptions)
    .then((res) => {
      return this.getCheck(res);
    });
}

In my App component I call this method: const res = api.getCards(); But in my console I do not see data. It's just promise. Why? How I can use res with data in my App component?

Samathingamajig
  • 11,839
  • 3
  • 12
  • 34
elarri
  • 5
  • 2
  • "*in my console I do not see data.*" - nothing in the code you've posted does print anything to the `console`, so why do you expect to see anything? – Bergi Feb 17 '23 at 19:35

0 Answers0