Answer the question
In order to leave comments, you need to log in
Property 'value' does not exist on type 'Promise'.?
// api/Category.ts
export function getCategories() {
return axios
.get("http://comfort.loc/api/categories/list")
.then((response) => response.data);
}
// App.tsx
useEffect(() => {
let categories = getCategories();
console.log(categories.value) // ошибка Property 'value' does not exist on type 'Promise<any>'.
}, []);
Answer the question
In order to leave comments, you need to log in
You need to wait for asynchronous code that returns a Promise , use async/await or then() chains
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question