Posts

Showing posts from February, 2021

Why Axios for API integration

Image
  When i started using react, i was wondering, how to connect to Rest API from UI. I started searching library which can be used to fulfill this purpose. Then, i turn towards fetch api and axios api. I started studying about both the libraries before actually using it. Then, i decided to use the axios library, and try to compare both the libraries. Below are the some features, which makes axios more powerful : Making simultaneous requests using axios.all 2. Sending custom headers 3. Automatically transforming requests and responses in json data 4. Cancelling request 5. Axios I s  More Secure, Featuring Built In Cross Site Forgery (XSRF) Protection 6. Monitor POST Request Progress 7. Axios Has A Wider Range Of Supported Browsers 8.Better error handling Browsers Support : Stay tuned for more updates !!!! Happy reading :)

Sort map by value using java 8 features

Image
  Generally, we sort the values by using keys. In case of map in java, we have a habit to sort keys, not values. But, there can be some scenarios , where we need to sort data based on values in map. I faced this challenge while working on one of my projects, where i need to do sorting based on values in hashmap. Then, i try to search easy way to achieve that, and found the api in java to do this job. I am excited to s h are with everyone , feature of java8 which makes my life easy, infact my coding life easy. I will show you both the code, before using java 8 features, and along with java 8 features. You will see the difference. Before java 8, code was like: sort unsortedFruits map with comparator Using java 8 features : sorting using java 8 features Code is clean and one liner to sort the map by values, not keys. You can download and run the complete code by downloading from my github link  https://github.com/kavitagupta972/MyWork/blob/master/Sorting%20Map.zip Hope you find t...

Axios — API Integration in Reactjs with hooks

Image
  To fetch data from a REST API, we send the AJAX request to server through some protocol, to get the requested response. There are different ways of doing this, by basic way of creating a   XHRequest  as well. Few of the other ways are: fetch 2.  axios 3.  superagent In this article, we will discuss Axios. Axios is a Promise-based HTTP client for JavaScript which can be used in your front-end application and node.js. It makes it easy to send HTTP requests to the server, to perform CRUD operations. Features of Axios : Axios su p ports operations in a variety of ways and provides so many features to make an easy task for developers to use this library. Features Make  XMLHttpRequests  from the browser Make  http  requests from node.js Supports the  Promise  API Intercept request and response Transform request and response data Cancel requests Automatic transforms for JSON data Client side support for protecting against  XSRF Bett...