From 1b0930ee757579010b13100c7e714e2f791ce203 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Mon, 30 Oct 2023 23:35:39 +0200 Subject: [PATCH] feat: add simple example --- README.md | 7 ++----- examples/simple.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 examples/simple.js diff --git a/README.md b/README.md index 6a60886..4369e9f 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,7 @@ Support is available on the [GameDig Discord](https://discord.gg/NVCMn3tnxH) (fo See the [GAMES_LIST.md](GAMES_LIST.md) file for the currently supported titles, not yet supported ones and notes about some of them. ## Usage from Node.js -Install... -```shell -npm install gamedig -``` -... then use! +Install using your favorite package manager:`npm install gamedig`, then use! ```js import GameDig from 'gamedig'; @@ -28,6 +24,7 @@ GameDig.query({ console.log("Server is offline"); }); ``` +Confused on how this works, or you want to see more? Checkout the [examples](/examples) folder! ## Query Options diff --git a/examples/simple.js b/examples/simple.js new file mode 100644 index 0000000..3f4a23b --- /dev/null +++ b/examples/simple.js @@ -0,0 +1,11 @@ +import GameDig from '../lib/index.js' +// Instead of '../lib/index.js' you would have here 'gamedig'. + +GameDig.query({ + type: 'minecraft', + host: 'mc.hypixel.net' +}).then((state) => { + console.log(state) +}).catch((error) => { + console.log(`Server is offline, error: ${error}`) +})