0.2.0 • Published 4 months ago

greengame-api-client v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

io-api-client

A REST API client for the GreenGame laboratory project.

Installation

This library is written as ESM module. To use it your project needs to use ESM modules too. First of all you have to set your script tag type to module:

<script type="module" src="main.js"></script>

Then you can import the client in your main.js file:

import {getUserData, updateRanking} from "https://unpkg.com/greengame-api-client@latest";

and use the functions as described below:

const userData = await getUserData();
console.log(userData.username);

A full example can be found in the example folder.

Getting auto-completions and typechecking

A full example that has auto-completions can be found in the example folder.

Above is the simplest way to use the client, but you won't get any auto-completions in your IDE.

To get auto-completions you have to setup TypeScript and install the client via npm. The easiest way to do so it by copying files from the example folder into your project, namely:

Also, the example tsconfig.json file has been configured to look for files in the src folder, so your JS files should be in the src folder.

Then you have to install the dependencies via npm:

npm install

This requires you to have npm installed. If you don't have npm installed, you can download it here.

Then you have to add the importmap script to your html file:

<script type="importmap">
{
    "imports": {
        "greengame-api-client": "https://unpkg.com/greengame-api-client@latest"
    }
}
</script>

And add your main.js below the script tag:

<script src="src/main.mjs" type="module"></script>

This should give you auto-completions in your IDE:

0.2.0

4 months ago

0.1.2

5 months ago

0.1.3

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago

0.0.8

5 months ago

0.0.7

5 months ago

0.0.6

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago