michael-spengler / api

Promise based HTTP client for the Deno.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

demoofqcom

API

Promise based HTTP client for the browser and Deno.

Getting Started

import api from 'https://deno.land/x/api/index.ts' // For Ts
// import api from 'https://deno.land/x/api/index.js' // For JS

console.log(await api.get('https://jsonplaceholder.typicode.com/todos/'))

console.log(await api.getone('https://jsonplaceholder.typicode.com/todos/',1))

console.log(await api.post('https://jsonplaceholder.typicode.com/todos/',{
    userId: 5,
    title: "excepturi a et neque qui expedita vel voluptate",
    completed: false
}))
console.log(await api.delete('https://jsonplaceholder.typicode.com/todos/1'))
console.log(await api.put('https://jsonplaceholder.typicode.com/todos/1',{
    userId: 1,
    title: "one",
    completed: true
}))

Run

deno run -A file_name.ts

Configuration

Use api.get : For Get Method.

console.log(await api.get('https://jsonplaceholder.typicode.com/todos/'))

Use api.getone : For GetOne Method.

console.log(await api.getone('https://jsonplaceholder.typicode.com/todos/',1))

Use api.post : For Post Method.

console.log(await api.post('https://jsonplaceholder.typicode.com/todos/',{
    userId: 5,
    title: "excepturi a et neque qui expedita vel voluptate",
    completed: false
}))

Use api.delete : For Delete Method.

console.log(await api.delete('https://jsonplaceholder.typicode.com/todos/1'))


Use api.put : For Put Method.

console.log(await api.put('https://jsonplaceholder.typicode.com/todos/1',{
    userId: 1,
    title: "one",
    completed: true
}))

License

MIT

About

Promise based HTTP client for the Deno.

License:MIT License


Languages

Language:JavaScript 70.4%Language:TypeScript 29.6%