react-server-request

1.1.1 • Public • Published

react-server-request

react-server-request

Browser Support

Chrome Firefox Safari Opera Edge IE
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);
  });

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i react-server-request

      Weekly Downloads

      1

      Version

      1.1.1

      License

      ISC

      Unpacked Size

      4.42 kB

      Total Files

      4

      Last publish

      Collaborators

      • piyas