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

rnfetchapi

v1.0.7

Published

A simple utility for making API calls using fetch in JavaScript or TypeScript

Downloads

20

Readme

RnFetchApi

RnFetchApi is a simple utility for making API calls using the fetch function in React Native. It provides easy-to-use shorthand methods for common HTTP methods such as GET, POST, PUT, and DELETE, and allows you to configure a base URL for your API requests.

Installation

You can install the rnfetchapi package via npm:

npm install rnfetchapi

Usage

To use the RnFetchApi in your React Native project, import it as follows:

import RnFetchApi from 'rnfetchapi';

Configuration

Before making any API calls, you can configure a base URL by calling the config method:

RnFetchApi.config("https://api.example.com/");

Making API Calls

GET Request

To make a GET request, use the get method:

RnFetchApi.get("someendpoint", "your_access_token_here")
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle errors
    console.error(error);
  });
POST Request

To make a POST request, use the post method:

const postData = {
  
  formData: { key: "value" },
  typecontent: false,
  token: "your_access_token_here",
};

RnFetchApi.post("someendpoint", postData)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle errors
    console.error(error);
  });
PUT Request

To make a PUT request, use the put method:

const putData = {
 
  formData: { key: "updated_value" },
  typecontent: false,
  token: "your_access_token_here",
};

RnFetchApi.put("someendpoint", putData)
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle errors
    console.error(error);
  });
DELETE Request

To make a DELETE request, use the del method:

RnFetchApi.del("someendpoint", "your_access_token_here")
  .then((response) => {
    // Handle the response
    console.log(response);
  })
  .catch((error) => {
    // Handle errors
    console.error(error);
  });
CUSTOM HEADER

when making a GET request (or any other API call), you can include custom headers in the customHeaders object to send them along with the request. This provides flexibility for users to add any additional headers they might need for specific API calls.

const customHeaders = {
 "X-Custom-Header": "Custom Value",
 "Authorization": "Custom Token",
};

RnFetchApi.get("someendpoint", "your_access_token_here", customHeaders)
 .then((response) => {
   // Handle the response
   console.log(response);
 })
 .catch((error) => {
   // Handle errors
   console.error(error);
 });

As shown in the code above, you can pass the customHeaders object as the third parameter to the post, put, and del methods to include any custom headers you want in the request. This allows you to send additional information, such as authentication tokens or any other headers required by the API endpoint.

License

This package is open-source and available under the MIT License.

Contribution

Contributions are welcome! If you find any bugs or want to suggest improvements, please feel free to create an issue or submit a pull request.

Summary

RnFetchApi simplifies making API calls in React Native using the fetch function. It provides a straightforward way to handle common HTTP methods and offers a convenient configuration to set a base URL for API requests. It is a reliable and easy-to-use fetch utility, making it an ideal choice for API calls in your React Native projects.