1.0.0 • Published 6 years ago

codebottle.io v1.0.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

Install

npm i -g codebottle.io

yarn add codebottle.io

Usage

All requests return promise

Request is never sent until you call one of HTTP methods

import bottle from 'codebottle.io';

// somewhere in async function
const { data } = await bottle.snippets('f063cc6e0b').get();

console.log(data.title);

You can pass query data to HTTP method call

bottle.snippets('new').post({ my: 'awesome query' }).then(...);

You will only need HTTP methods .get and .post but you can use any other that snekfetch supports

bottle.snippets().get({ foo: 'bar' }).then(...);
bottle.snippets().post({ foo: 'bar' }).then(...);

// API doesn't support it but you are still able to do this
bottle.snippets().search({ foo: 'bar' }).then(...);

API URL constructing

To make working api url you just need to follow codebottle.io API endpoints docs

// Current supported functions: snippets,languages,categories

// GET /snippets
bottle.snippets() // .get()

// GET /snippets/1
bottle.snippets(1) // .get()
bottle.snippets('1') // .get()

// GET /languages/1
bottle.languages(1) // .get()


// If there are any unsupported functions

// GET /users/1
bottle.users[1] // .get()

// GET /users/devcat
bottle.users.devcat // .get()
bottle.users['devcat'] // .get()
1.0.0

6 years ago