All Projects → eldomagan → Axios Rest

eldomagan / Axios Rest

Licence: mit
A simple axios wrapper to make rest api call delightful

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Axios Rest

Apipie
Transform api declaration to js object for frontend. Inspired by VueRouter, koa-middleware and axios.
Stars: ✭ 29 (-29.27%)
Mutual labels:  api, rest, axios
Vuex Rest Api
A utility to simplify the use of REST APIs with Vuex
Stars: ✭ 365 (+790.24%)
Mutual labels:  api, rest, axios
Restyped
End-to-end typing for REST APIs with TypeScript
Stars: ✭ 287 (+600%)
Mutual labels:  rest-api, rest, axios
Wp Rest Api Cache
Enable caching for WordPress REST API and increase speed of your application
Stars: ✭ 239 (+482.93%)
Mutual labels:  api, rest-api, rest
Spyke
Interact with REST services in an ActiveRecord-like manner
Stars: ✭ 591 (+1341.46%)
Mutual labels:  api, rest-api, rest
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+517.07%)
Mutual labels:  api, rest-api, rest
Kanary
A minimalist web framework for building REST APIs in Kotlin/Java.
Stars: ✭ 319 (+678.05%)
Mutual labels:  api, rest-api, rest
Magic
Create your .Net Core/Angular/Database CRUD Web apps by simply clicking a button
Stars: ✭ 214 (+421.95%)
Mutual labels:  api, rest-api, rest
Discord4j
Discord4J is a fast, powerful, unopinionated, reactive library to enable quick and easy development of Discord bots for Java, Kotlin, and other JVM languages using the official Discord Bot API.
Stars: ✭ 973 (+2273.17%)
Mutual labels:  api, rest-api, rest
Networking
⚡️ Elegantly connect to a REST JSON Api. URLSession + Combine + Decodable + Generics = <3
Stars: ✭ 499 (+1117.07%)
Mutual labels:  api, rest-api, rest
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+8309.76%)
Mutual labels:  api, rest-api, rest
Apidoc
RESTful API 文档生成工具,支持 Go、Java、Swift、JavaScript、Rust、PHP、Python、Typescript、Kotlin 和 Ruby 等大部分语言。
Stars: ✭ 785 (+1814.63%)
Mutual labels:  api, rest-api, rest
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (+431.71%)
Mutual labels:  api, rest-api, rest
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+129295.12%)
Mutual labels:  api, rest-api, rest
Symfony Flex Backend
Symfony Flex REST API template project
Stars: ✭ 214 (+421.95%)
Mutual labels:  api, rest-api, rest
Vulcain
Fast and idiomatic client-driven REST APIs.
Stars: ✭ 3,190 (+7680.49%)
Mutual labels:  api, rest-api, rest
Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (+365.85%)
Mutual labels:  api, rest, resource
Jikan Rest
The REST API for Jikan
Stars: ✭ 200 (+387.8%)
Mutual labels:  api, rest-api, rest
Javacord
An easy to use multithreaded library for creating Discord bots in Java.
Stars: ✭ 368 (+797.56%)
Mutual labels:  api, rest-api, rest
Rest Api Nodejs Mongodb
A boilerplate for REST API Development with Node.js, Express, and MongoDB
Stars: ✭ 672 (+1539.02%)
Mutual labels:  api, rest-api, rest

Axios Rest

A simple axios wrapper to make rest api call delightful.

Example

const axiosRestClient = require('axios-rest-client')
const api = axiosRestClient({baseUrl: process.env.API_BASE_URL})

// Get all users
api.users.all().then(response => {
  console.log(response.data)
})

// Create new user
api.users.create({
  firstname: 'John',
  lastname: 'Doe'
})

Installation

npm install --save axios-rest-client

axios-rest require axios to work, so you have to install axios

npm install --save axios

How to use it ?

Create your axios rest client

const axiosRestClient = require('axios-rest-client')

const api = axiosRestClient({
  baseUrl: process.env.API_BASE_URL // this is required
  // see axios for other configuration options
})

And that all ! You can start requesting your api

Start by creating endpoint for your resources

// Create multiple resources endpoints
api.endpoints({
  users: 'users',           // /users endpoint
  posts: 'post-resources'  // /post-resources endpoint
})

api.endpoint('users')   // Create /users endpoint

// You can access previously endpoint as attribute
// If the endpoint does not exist it will be created automatically
api.users
api.comments    // get endpoint for comments on /comments

You can then call

api.users.all()               // GET /users
api.users.find(1)             // Get /users/1
api.users.create(data)        // POST /users, body=data
api.users.update(1, data)     // PUT /users/1, body=data
api.users.delete(1)           // DELETE /users/1

If you want to create an api endpoint for a single instance of a collection just call .one(instanceId) on the collection endpoint.

api.users.one(1)  // Create entity endpoint for user with id 1
// or simply do
api.users[1]      // to get the /users/1 endpoint automatically created for you

You can the call

api.users[1].get()        // GET /users/1
api.users[1].post(data)   // POST /users/1, body = data
api.users[1].put(data)    // PUT /users/1, body = data
api.users[1].delete()     // DELETE /users/1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].