I have this issue in the yellowBox (React Native)
Possible Unhandled Promise Rejection (id: 2): TypeError: _petition.default.getCategory is not a function TypeError: _petition.default.getCategory is not a function at api$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:104932:33) at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26922:19) at Generator.invoke [as _invoke] (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27098:24) at Generator.prototype. [as next] (http://localhost:8081/index.bundle?........
and my code of the petition is the following:
class petition {
async getCategories() {
try {
const response = await fetch('https://yts.mx/api/v2/list_movies.json');
const data = await response.json();
return data.data.movies;
} catch (error) {
console.log(`error ocurred:${error}`);
}
}
async getRecommendations(id) {
try {
const response = await fetch(
`https://yts.mx/api/v2/movie_suggestions.json?movie_id=${id}`,
);
const rawData = await response.json();
return rawData.data.movies;
} catch (error) {
console.log(`error ocurred (${error})`);
}
}
}
export default new petition();
getCategory
function, or function call. Where is that defined and being called? – Jayce444export default new petition();
.... odd pattern - is there a reason for it? – Roamer-1888