# @nslibs/nsapi-client

> Project that handles requests and authentication with NSAPI

Latest version **0.0.2** (published 2020-04-27) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @nslibs/nsapi-client
pnpm add @nslibs/nsapi-client
yarn add @nslibs/nsapi-client
bun add @nslibs/nsapi-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-04-27 |
| First published | 2020-04-23 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 86 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | naturescape |

## Links

- npm: https://www.npmjs.com/package/@nslibs/nsapi-client
- npm.io page: https://npm.io/package/@nslibs/nsapi-client

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.4

## Recent versions

- 0.0.2 (latest) — 2020-04-27
- 0.0.1 — 2020-04-23

## README

# NSApiClient

Project that handles requests and authentication with NSAPI

## Installation

Using npm:
```
$ npm i @nslibs/nsapi-client
```

Using cdn:
```javascript
<script src="https://unpkg.com/@nslibs/nsapi-client@0.0.2/dist/nsapi-client.js"></script>
```

## Usage

```javascript
let nsapi = new NSApiClient(url, {
    api_key,
    session_id,
    retry_limit: 3, // limit # of retries before throwing err
    retry_delay: 1000, // ms to wait between request attempts
});
```

##### Node.js

```javascript
let NSApiClient = require('@nslibs/nsapi-client');

let nsapi = new NSApiClient('https://example.com/graphql');

try {
    await nsapi.login("user", "password");

    let res = await nsapi.request({
        query,
        variables, //optional
        api_key, //optional
        session_id, //optional
    });
} catch (err) {
    console.log(err); // => NSApiError: There was an error
}
```

##### Browser

```javascript
    <script src="unpkg.com/@nslibs/nsapi-client"></script>

    <script>
        let nsapi = new NSApiClient('https://example.com/graphql');

        try {
            await nsapi.login("id", "password");

            return await nsapi.request({
                query,
                variables, //optional
                api_key, //optional
                session_id, //optional
            });
        } catch (err) {
            alert(err.message);
        }
    </script>
```

---
_Source: https://npm.io/package/@nslibs/nsapi-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
