Vârli
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_KEY Recommended threads
- Session sign-out and sign-back-in issues...
Session sign-out and sign-back-in issues with records from the database In a Flutter application I am testing signing a user in, you can see the user’s records...
- flutter: Get users error: AppwriteExcept...
nothing is working are the servcies down ?
- Messages stuck on processing
On the Messaging section of my Cloud console, I have 16 emails and push notifications that have been stuck on processing for months. They didn't get sent and wo...