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))
| 1. Build GraphQL server using `express-graphql` package. | |
| 2. Configure `schema.js` file. | |
| 3. Query for data. |
| /* ********** 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 |