npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-restful-client

v1.0.0

Published

Your RESTful client for React Native or anything else

Readme

React Native REST Client

Simplify the RESTful calls of your React Native (but all other JavaScript) app.

This is a fork of react-native-rest-client.

Installation

yard add react-native-restful-client

Usage

Create a new class which extends the RestfulClient class

import RestfulClient from 'react-native-restful-client'

export default class UsersApi extends RestfulClient {
  constructor () {
    super(
      'https://myapp.com/api', {    // The base URL of the API to consume
        resource: 'users'           // The resource of the API to consume
    })
  }
}

From now on, the UsersApi class is able to call all the CRUD methods of the RESTful API:

const usersApi = new UsersApi()

usersApi.all() // Calls a GET on https://myapp.com/api/users

usersApi.get(1) // Calls a GET on https://myapp.com/api/users/1

usersApi.create({ name: 'zedtux' }) // Send a POST to https://myapp.com/api/users

usersApi.update(2, { name: 'john' }) // Send a PATCH to https://myapp.com/api/users/2

usersApi.destroy(2) // Send a DELETE to https://myapp.com/api/users/2

You can also request non CRUD actions :

const usersApi = new UsersApi()
usersApi.request(
  'POST',
  path: 'auth',
  body: {
    'johndoe',
    'p4$$w0rd'
  }).then(response => response.token)   // Successfully logged in
    .then(token => saveToken(token))    // Remember your credentials
    .catch(err => alert(err.message))  // Catch any error

Authentication example with JWT

import RestfulClient from 'react-native-rest-client'

export default class UsersApi extends RestfulClient {
  constructor (authToken) {
    super('https://api.myapp.com', {
      headers: {
        // Include as many custom headers as you need
        Authorization: `JWT ${authToken}`
        // Content-Type: application/json
        // and
        // Accept: application/json
        // are added by default
      },
      // Simulate a slow connection on development by adding
      // a 2 second delay before each request.
      devMode: __DEV_,
      simulatedDelay: 2000
    })
  }

  getWeather (date) {
    // The body object will be used to build a query.
    // For example, in the case `date` is `{ "lt": "2018/07/13" }` the GET query
    // will be https://api.myapp.com/weather?lt="2018/07/13"
    return this.request('GET', path: '/weather', body: { date })
               .then(response => response.data)
  }

  checkIn (lat, lon) {
    return this.request('POST', path: '/checkin', body: { lat, lon })
  }
}

Limitations

  • This library only supports JSON request and response bodies. If the response is not a JSON object, it will throw a JSON parse error. If the response is empty, it will return undefined.
  • It is labeled as React Native, even when it has no RN dependencies and could (in theory) be used in any JavaScript project. The reason behind this is that the stack used (ES6 and fetch) comes out of the box with React Native, and adding support for more platforms would require to add pre-compilers, polyfills and other tricks, which are completely out of the scope of this library. If you know what you're doing though, feel free to tweak your stack and use this library.

License

MIT