• Using axios interceptors in Frontend
    Using axios interceptors in Frontend

    Axios is the go-to library for managing HTTP requests in web development. While many developers have started using the native fetch API, if your requirements are more complex and you need a reliable solution, Axios remains the top choice. It offers a range of built-in features that are either challenging or not feasible to achieve with fetch. Interceptors are such a feature in Axios that allows us to intercept HTTP requests or responses, making it possible to implement useful patterns that enha

    Read More
  • Organizing API calls in frontend - why & how
    Organizing API calls in frontend - why & how

    API calls are often a significant part of most web applications, if not the most critical aspect. However, many projects lack proper organization for these calls, leading developers to scatter API calls throughout the codebase. Why should we care? Maintainability: Writing API calls haphazardly can quickly lead to a tangled mess. This approach often results in repeated imports of API libraries across various files, leading to code duplication and increased chances of errors. By centralizing AP

    Read More
  • Sequential promise chain and promise chunking in javascript
    Sequential promise chain and promise chunking in javascript

    💡Prerequisite: Javascript Array.prototype.reduce and Promise While dealing with a group of promises, we usually want to run them in parallel to improve performance. Promise.all is our friend in this case. We group our promises in an array and pass it into Promise.all const promises = [promise1, promise2, promise3]; Promise.all(promises).then(data => { console.log(data); // [result1, result2, result3] }) But sometimes, a situation may arise when we can't run the promises concurrently even i

    Read More