
I have this code to make a get request to an API
TypeScript
function fetchUserListPerPage(page) {
return new Promise(async (resolve, reject) => {
try {
const response = await axios
.get(`${process.env.CHARA_API_URL}/api/v1/bestvalue/b2b/customer/list?_ipp=100&_p=${page}`, {
headers: {
Authorization: `${process.env.CHARA_API_KEY}`
}
});
resolve(response.data);
} catch(error) {
console.log(error);
reject({ Content: { Records: [] } });
}
});
}
And sometimes the request fails with the getaddrinfo EAI_AGAIN error
TL;DR
Code is making a GET request using axios to an API, sometimes resulting in a getaddrinfo EAI_AGAIN error. This error typically occurs due to DNS lookup failure. Adding a timeout option in axios to handle this error might help:
```javascript
function fetchUserListPerPage(page) {
return new Promise(async (resolve, reject) => {
try {
const response = await axios
.get(`${process.env.CHARA_API_URL}/api/v1/bestvalue/b2b/customer/list?_ipp=100&_p=${page}`, {
headers: {
Authorization: `${process.env.CHARA_API_KEYRecommended threads
- No access control allow origin -blocked ...
im not sure what exaclty im doing wrong - its my first time using appwrite - and im watching a tutorial about how to create a movie app and followed everything ...
- Number of Database Reads Bugged
My Appwrite project is generating a huge amount of database reads even when all my apps are closed and no one is using it. The reads counter keeps going up. (it...
- [SOLVED] Appwriteexception: invalid redi...
I've been following this documentation on my app: https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-7 On Localhost and local development, it's working fi...
