Skip to content

Playful-Systems/conduit

Repository files navigation

Conduit

An axios like http client that uses fetch under the hood.

NPM Package

Instantiating

import { Conduit } from '@packages/conduit';

const conduit = Conduit.create({
  baseURL: 'https://jsonplaceholder.typicode.com',
});

Requests

Conduit supports all the popular request methods.

GET

const response = await conduit.get('/posts');
const posts = response.data;

POST

const response = await conduit.post('/posts', {
  title: 'foo',
  body: 'bar',
  userId: 1,
});
const post = response.data;

PUT

const response = await conduit.put('/post', {
  id: 1,
  title: 'foo',
  body: 'bar',
  userId: 1,
});

PATCH

const response = await conduit.patch('/post', {
  id: 1,
  title: 'foo',
});

DELETE

const response = await conduit.delete('/post', {
  id: 1,
});

About

An axios inspired http client that uses fetch under the hood.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •