HTTP Client for React Apps
Installing
npm install react-http-client
Uses
The handler takes 3 args
- URL
- Body : default {}
- Headers : default {}
; // or const httpHandler = ; const postResponse = await httpHandler; console;// {// status: 'success',// data: { name: 'test', salary: '123', age: '23', id: 66 }// } const getResponse = await httpHandler; console; // {// status: 'success',// data: [// {// id: '1',// employee_name: 'Tiger Nixon',// employee_salary: '320800',// employee_age: '61',// profile_image: ''// },// {// id: '2',// employee_name: 'Garrett Winters',// employee_salary: '170750',// employee_age: '63',// profile_image: ''// },// {// id: '3',// employee_name: 'Ashton Cox',// employee_salary: '86000',// employee_age: '66',// profile_image: ''// },// ...// ...// ]// }
You can also use inbuilt fetch to do the same but this will provide you a simple interface with which you can make calls easily.
-- Thanks