@kreisler/createapi
v1.0.0
Published
Un forma sensilla de hacer peticiones a una API
Downloads
15
Readme
Create API
Create API is a simple package to create API requests with ease.
Usage
Install package
npm i @kreisler/createapi
Import module
import { createApi } from "@kreisler/createapi";
or
Import commonjs
const { createApi } = require("@kreisler/createapi");
Example #1
(async () => {
// createApi
const api = createApi('https://nekobot.xyz/api')
const output = await api.image({ type: 'neko' })
// final url: https://nekobot.xyz/api/image?type=neko
console.log({ output })
// output:
// {
// "success": true,
// "message": "https://i0.nekobot.xyz/7/0/6/217595fa8b7cae5b7f6524169230c.png",
// "color": 13419230,
// "version": "2021070801"
// }
})();
Example #2
(async () => {
// createApi
const api = createApi('https://api.adviceslip.com')
const output = await api.advice()
// final url: https://api.adviceslip.com/advice
console.log({ output })
/**
* {
* output: { slip: { id: 189, advice: 'Do not compare yourself with others.' } }
* }
*/
})();