2.0.0 • Published 3 years ago

@neocord/rest v2.0.0

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
3 years ago

Simple REST library used within neocord

node.js v14 or newer is required.

yarn add @neocord/rest

Basic Usage

import { REST } from "@neocord/rest";
import fetch from "petitio";

const api = new REST();

// You must set the token if you want to use the RestHandler, cdn doesn't require a authorization.
api.token = "your token here"

// All (iirc) REST routes return JSON, the CDN does not.
api.queue("/users/@me").then(console.log);
...

// If you wanna use the CDN you need to use petitio, or another http client of your choice.
const defaultAvatar = await fetch(api.cdn.defaultAvatar("5773"));
console.log(defaultAvatar.body) // => <Buffer 89 50 4e 47...>

Typescript Users

Because we make use of petitio you may have to install undici as a development dependency.