Common Things API
is an open-source package that looks forward in providing a developer-friendly experience when making network request as it provides tons of api and pre-configuration of each api that can be consumed with just a single line of code without having you to craft out a logical network request saving time and lines of code. A product of lots of commonly used apis as listed below:
Let grow the list together by contributing.
You’ll need to have Node 10.16.0 or later version on your local development machine (but it’s not required on the server). I recommend using the latest LTS version.
To create a new app, you have to:
Begin by
- Fork the repo
- Clone this repository to establish your own local copy. This process is straightforward and ensures you have all the necessary files and resources at your fingertips. You can find step-by-step instructions in this helpful article: Cloning a repository on GitHub.com.
- Run the app using the command
npm i
- Check the
src
folder to get on with the codebase.
rollupjs
- The JavaScript module bundler
You can re-use this for whatever you want or to build something cool with it.
$ npm install @certsoftt/common-things-api@1.0.0
or
$ npm i common-things-api
"@certsoftt/common-things-api": "1.0.0"
- Using the
Get class
to fetch data.
For instance, fetchingposts
fromjsonplaceholder api
import {Get} from "common-things-api"
//or import {Get} from "@certsoftt/common-things-api"
let posts = new Get("posts").api()
this fetches posts from jsonplaceholder api. The api()
accepts 1 optional argument which is your endpoint query. For instance, fetching a single post with an id
of 50
let post = new Get("posts").api("?id=50")
or programmatically:
let id = value // dynamic value
let post = new Get("posts").api(`?id=${id}`)
Licensed under the MIT license.