RailsRanger

RailsRanger

new RailsRanger(configs)

RailsRanger object constructor

Source:
Parameters:
Name Type Description
configs object

Configurations to be handed to Axios.

Methods

create(resource, params) → {Promise}

Makes a POST request to the create path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.create('users', { email: 'john@doe.com', password: 123456 })
//=> POST request to '/users' path with the { email: 'john@doe.com', password: 123456 } parameters

delete(path, params) → {Promise}

Makes a DELETE request to the given path with the given parameters

Source:
Parameters:
Name Type Description
path string

The base path of the request

params object

The parameters to be injected in the path (as query or replacing path segments)

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.delete('/users/:id', { id: 1, flag: true })
//=> DELETE request to '/users/1?flag=true' path

destroy(resource, params) → {Promise}

Makes a DELETE request to the destroy path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Name Type Description
id number | string

The id of the resource

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.destroy('users', { id: 1, flag: true })
//=> DELETE request to '/users/1?flag=true' path

edit(resource, params) → {Promise}

Makes a GET request to the edit path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Name Type Description
id number | string

The id of the resource

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.edit('users', { id: 1, flag: true })
//=> GET request to '/users/1/edit?flag=true' path

get(path, params) → {Promise}

Makes a GET request to the given path with the given parameters

Source:
Parameters:
Name Type Description
path string

The base path of the request

params object

The parameters to be injected in the path (as query or replacing path segments)

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.get('/users/:id', { id: 1, flag: true })
//=> GET request to '/users/1?flag=true' path

list(resource, params) → {Promise}

Makes a GET request to the index path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.list('users', { flag: true })
//=> GET request to '/users?flag=true' path

new(resource, params) → {Promise}

Makes a GET request to the new path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.new('users', { flag: true })
//=> GET request to '/users/new?flag=true' path

patch(path, params) → {Promise}

Makes a PATCH request to the given path with the given parameters

Source:
Parameters:
Name Type Description
path string

The base path of the request

params object

The parameters to be injected in the path or sent in the request payload

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.patch('/users/:id', { id: 1, flag: true })
//=> PATCH request to '/users/1' path with { flag: true } parameters

post(path, params) → {Promise}

Makes a POST request to the given path with the given parameters

Source:
Parameters:
Name Type Description
path string

The base path of the request

params object

The parameters to be injected in the path or sent in the request payload

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.post('/users/:id', { id: 1, flag: true })
//=> POST request to '/users/1' path with { flag: true } parameters

put(path, params) → {Promise}

Makes a PUT request to the given path with the given parameters

Source:
Parameters:
Name Type Description
path string

The base path of the request

params object

The parameters to be injected in the path or sent in the request payload

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.put('/users/:id', { id: 1, flag: true })
//=> PUT request to '/users/1' path with { flag: true } parameters

show(resource, params) → {Promise}

Makes a GET request to the show path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Name Type Description
id number | string

The id of the resource

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.show('users', { id: 1, flag: true })
//=> GET request to '/users/1?flag=true' path

update(resource, params) → {Promise}

Makes a PATCH request to the update path of the given resource

Source:
Parameters:
Name Type Description
resource string

The base path of the request

params object

The parameters to be injected in the path as query

Name Type Description
id number | string

The id of the resource

Returns:
Type:
Promise
Example
let api = new RailsRanger
api.update('users', { id: 1, email: 'elton@doe.com' })
//=> PATCH request to '/users/1' path with the { email: 'elton@doe.com' } parameters