1.0.5 • Published 6 years ago

@bsaqqa/requestsgenerator v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

@bsaqqa/requestsgenerator

GitHub license npm (scoped)

Generate requests without need writing full request every time

Install

npm i @bsaqqa/requestsgenerator

or

yarn add @bsaqqa/requestsgenerator

Usage

    import API  from '@bsaqqa/requestsgenerator';
    
    API.setUrl('http://example.com/api/');
    API.http.getProjects({page:1})
    .then(response=>response.json())
    .then(resp=>{
        console.log(resp);
    }).catch(err=>{
        throw new Error('Response is inncorrect.');
    });

more options

    // GET /
    API.http.get()
    // GET /users
    API.http.getUsers()
    // GET /users/1234/likes
    API.http.getUsers$Likes('1234')
    // GET /users/1234/likes?page=2
    API.http.getUsers$Likes('1234', {  page: 2  })
    // POST /items with body
    API.http.postItems({ name: 'Item name' })
    
    // other usage
    API.setUrl('http://example.com/api/', '?attr=abc' )
    // GET http://example.com/api/posts/123?attr=abc
    API.http.getPosts$('1234')
    // POST http://example.com/api/posts/123?attr=abc
    API.http.postPosts$('1234', {name: 'user name'})
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.0.1

6 years ago

1.0.0

6 years ago