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?