1.1.1 • Published 3 years ago

react-server-request v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 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

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'

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);
  });
1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago