1.0.2 • Published 4 years ago

axios-lite v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

react-server-request

react-server-request

Browser Support

ChromeFirefoxSafariOperaEdgeIE
Latest ✔Latest ✔Latest ✔Latest ✔Latest ✔11 ✔

Installing

Using npm:

$ npm i react-server-request
$ npm i axios-lite

Using bower:

$ bower i react-server-request

Using yarn:

$ yarn add react-server-request

use react-server-request simply:



// file name API.js
import {Request} from 'react-server-request'
import {Request} from 'axios-lite'

export default  new Request('here will be main path')

// this is like  ----->
// const API = new Request('https://jsonplaceholder.typicode.com')
 
// get request for loading data
// get request for loading data
import {API} from './api'

API.get('/here will be get request path')
// this is like  ----->
// const API = new Request('/users')
.then(res=>console.log(res))
.catch(function (error) {
    console.log(error);
import {API} from './api'
API.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
import {API} from './api'
API.delete('/user')
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
import {API} from './api'
API.put('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });