Skip to content

Instantly share code, notes, and snippets.

1. Build GraphQL server using `express-graphql` package.
2. Configure `schema.js` file.
3. Query for data.
@zaam-tech
zaam-tech / online_offline_detection.js
Created September 4, 2020 12:46 — forked from gitdagray/online_offline_detection.js
Online / Offline Status Detection w/ Async & Await
/* ********** Online / Offline Detection ********** */
// Request a small image at an interval to determine status
// ** Get a 1x1 pixel image here: http://www.1x1px.me/
// ** Use this code with an HTML element with id="status"
const checkOnlineStatus = async () => {
try {
const online = await fetch("/1pixel.png");
return online.status >= 200 && online.status < 300; // either true or false
@zaam-tech
zaam-tech / README.md
Created August 16, 2020 09:56 — forked from ekaranjaa/README.md
JavaScript HTTP🌐 library using async await and the fetch api

Usage

Import http.js in your index.js or the file you wish to call an api. Call your API 🚀

const req = new HTTP

req.get('http://my.api/users')
    .then(users => console.log(users))
    .catch(err => console.log(err))