Code Monkey home page Code Monkey logo

http-react's Introduction

HTTP React

Http React is a React hooks library for data fetching. It's built on top of the native Fetch API.

Overview

With one hook call, you get all the information about a request that you can use to build UIs that are consistent and performant:

import useFetch from 'http-react'

// This is the default
const fetcher = (url, config) => fetch(url, config)

export default function App() {
  const { data, loading, error, responseTime } = useFetch('/api/user-info', {
    refresh: '30 sec',
    fetcher
  })

  if (loading) return <p>Loading</p>

  if (error) return <p>An error ocurred</p>

  return (
    <div>
      <h2>Welcome, {data.name}</h2>
      <small>Profile loaded in {responseTime} miliseconds</small>
    </div>
  )
}

It supports many features that are necessary in modern applications, while giving developers full control over the request configuration:

  • Server-Side Rendering
  • Server actions
  • React Native
  • Request deduplication
  • Suspense
  • Refresh
  • Retry on error
  • Pagination
  • Local mutation (Optimistic UI)
  • qraphql

and more!

Installation:

npm install --save http-react

Or

yarn add http-react

For production apps

<!-- Add React and ReactDOM -->
<script
  src="https://unpkg.com/[email protected]/umd/react.production.min.js"
  crossorigin
></script>

<script
  src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"
  crossorigin
></script>

<!-- Add Http React -->
<script src="https://unpkg.com/http-react/dist/browser/http-react.min.js"></script>

Getting started

http-react's People

Contributors

danybeltran avatar gusgyocode avatar nelsondev19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

http-react's Issues

porque al final de la ruta al realizar una solicitud agrega el símbolo `?`

Tengo una pregunta, porque al hacer una peticion y colocar la ruta al final de la ruta me agrega el simbolo ?, por ejemplo tengo la consulta

const { reFetch } = useFetch('https://pokeapi.co/api/v2/pokemon/bulbasaur', {
    auto: false,
    method: 'GET',
    onResolve (data) {
      console.log(data)
    },
    onError (err) {
      console.log(err)
    }
  })

y en la ruta que aparece en el navegador es
https://pokeapi.co/api/v2/pokemon/bulbasaur? o https://pokeapi.co/api/v2/pokemon/bulbasaur/?
y al agregar ese simbolo hay rutas que me da error porque ese no es el path de la ruta

hay forma de quitar ese simbolo al hacer la peticion?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.