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 🙏

© 2025 – Pkg Stats / Ryan Hefner

zoe-data

v0.6.0-rc.7

Published

This library provides hooks to make your APIs calls.

Downloads

5

Readme

Zoe data

This library provides hooks to make your APIs calls.

Use Axios and receive axios params if you need 😉

Inspired by Apollo Client

This package is under construction and this doc will be updated

Installation

Yarn

yarn add zoe-data

NPM

npm install --save zoe-data

Hooks

All the hooks that modify data don't run at the moment they are created, for this use the fetch function they give to you.

All the hooks returns this, and they fetch functions return the same except for the loading.

Name | Type | Description | - | - | - | loading | boolean | Will be true when the request is running error | object | Will be the error if the request fails data | object | Will be the data if the request succeeds status | number | Will be the status code of the response axiosOriginalResponse | object | Will be the axios response fetch | function | Will be the fetch function that you can use to fetch the data, the name will change by hook

Example

import React from "react";
import { useDelete, useGet, usePost, useUpdate } from "../main";
import { ApiConfigProvider } from "../main/context/ApiConfig/ApiConfig.provider";

interface ResponseData {
  id: number;
  name: string;
}

interface RequestVars {
  name: string;
}

export function AllHooksExample() {
  const { data, loading, status, error, axiosOriginalResponse, refetch } =
    useGet<ResponseData>("/user");

  const { fetchPost } = usePost<ResponseData, RequestVars>("/user");

  const { fetchUpdate } = useUpdate<ResponseData, RequestVars>("/user");

  const { fetchDelete } = useDelete<ResponseData>("/user");

  const handlePost = async (vars: RequestVars) => {
    const created = await fetchPost(vars);
    if (created.data) {
      console.log(created.data);
    }
  };

  const handleUpdate = async (id: number, vars: RequestVars) => {
    const updated = await fetchUpdate(id, vars, {
      method: "PUT",
    });
    if (updated.data) {
      console.log(updated.data);
    }
  };

  const handleDelete = async (id: number) => {
    const deleted = await fetchDelete(id);
    if (deleted.data) {
      console.log(deleted.data);
    }
  };

  return (
    <div>
      <button onClick={() => handlePost({ name: "Gold D. Roger" })}>
        Post
      </button>
      <button onClick={() => handleUpdate(1, { name: "Monkey D Luffy" })}>
        update
      </button>
      <button onClick={() => handleDelete(1)}> delete </button>
    </div>
  );
}

function App() {
  return (
    <ApiConfigProvider axiosConfigParams={{ baseURL: "http://localhost:3001" }}>
      <AllHooksExample />
    </ApiConfigProvider>
  );
}

useGet

Will run a axios.get() and bring to you the data.

Usage

import React from "react";
import { useGet, ApiConfigProvider} from 'zoe-data'

function UseGetExample() {
  const { data, loading, status, axiosOriginalResponse } = useGet<GitHubResponse[]>(
    "/users/kennedy-f/repos"
  );

  if (status === 404) {
    console.log("error");
  }

  return <> {loading ? "loading" : JSON.stringify(data)}</>;
}

function App() {
  return (
    <ApiConfigProvider
      axiosConfigParams={{ baseURL: "https://api.github.com/" }}
    >
      <UseGetExample/>
    </ApiConfigProvider>
  );
}

useUpdate

Can be a axios.patch() or a axios.put(), by default is a axios.patch(). The route that you pass will be called with the ID in the fetchUpdate, if your route is /users and you call the fetchUpdate function will your request will be /users/$id.

Can't make multiple updates, just one ID per update, to make more create a custom hook or use an axios instance.

Usage

import React from 'react';
import {ZoeProvider, useUpdate} from 'zoe-data';

function Update() { 
  const { fetchUpdate } = useUpdate('/user')
  return <button onClick={() => fetchUpdate(1, { name: 'Monkey D. Luffyer' } ) }> update </button>
}

function App() { 
  return(
    <ZoeProvider axiosConfigParams={{baseURL: 'http://localhost:3001' }}> 
      <Update />
    </ZoeProvider>
  )
} 

Can receive generics for the variables and for the response data.

const {fetchUpdate} = useUpdate<ResponseData, RequestVars>('/users')

Custons routes

For customs routes you can pass a prop called custom Query, write you query with the custom field with $id, this string will be changed for the ID you pass through.

const {fetchUpdate} = useUpdate<ResponseData, RequestVars>('', { customQuery: '/users/$id/update' })

Change method

const {fetchUpdate} = useUpdate<ResponseData, RequestVars>('', { customQuery: '/users/$id/update', method: 'PUT' })

const handleUpdate = async (id: number, data: RequestVars) => {
    const updated = await fetchUpdate(id, data, {
      method: "PUT",
    });
    if (updated.data) {
      console.log(updated.data);
    }
  };

useDelete

Runs an axios.delete() and bring to you the data.

import React from 'react';

function Delete() {
  const { fetchDelete } = useDelete<ResponseData>("/user");
  return <button onClick={() => fetchDelete(1)}> delete </button>
}