# fb-ninja

> Makes batch requests to facebook API an easy task for you

Latest version **1.0.1** (published 2016-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install fb-ninja
pnpm add fb-ninja
yarn add fb-ninja
bun add fb-ninja
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-09-09 |
| First published | 2016-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ViktorKonsta |
| Maintainers | viktor.konsta |
| Keywords | facebook, fb, request, batch |

## Links

- npm: https://www.npmjs.com/package/fb-ninja
- Repository: https://github.com/ViktorKonsta/fb-ninja
- Homepage: https://github.com/ViktorKonsta/fb-ninja#readme
- Issues: https://github.com/ViktorKonsta/fb-ninja/issues
- npm.io page: https://npm.io/package/fb-ninja

## Dependencies (8)

- [co](https://npm.io/package/co.md) ^4.6.0
- [fb](https://npm.io/package/fb.md) ^1.1.1
- [delay](https://npm.io/package/delay.md) ^1.3.1
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) ^4.2.0
- [lodash.isnull](https://npm.io/package/lodash.isnull.md) ^3.0.0
- [lodash.isarray](https://npm.io/package/lodash.isarray.md) ^4.0.0
- [lodash.isfunction](https://npm.io/package/lodash.isfunction.md) ^3.0.8
- [lodash.isplainobject](https://npm.io/package/lodash.isplainobject.md) ^4.0.6

## Recent versions

- 1.0.1 (latest) — 2016-09-09
- 0.0.0 — 2016-09-06

## README

# fb-ninja
Makes batch requests to facebook API an easy task for you

## Features

- Can handle a lot of API calls by split and defer them
- Accept callbacks `before`, `after`, `afterEach`, `beforeEach`
- Lightweight and fast

## Install

```
npm install --save fb-ninja
```

## Get started

```js
const ninja = require("fb-ninja")

// define what you need for every request
const request = {
  method: "get",
  api: "me/accounts"
}

// top level access token
const options = { accessToken: process.env.ACCESS_TOKEN }

// get all result in one place as well as result per request
// place as many requests as you want
ninja(request, options)
  .then(detailedResult => console.log(detailedResult))
  .catch(err => console.error(err))
```

## Arguments

### Request

It's the first parameter. All of them reffers to the api call itself.  
**Message or link are required. It's part of facebook field itself.**

| Required | Key | Descripiton | Type | Default
| :--- | :--- | :--- | :--- | :---
| yes | `accessToken` | Low level access token | `String` |
| yes | `message` | `Message` or `link` are required | `String` |
| no | `link` | `Message` or `link` are required | `String` |
| no | `method` | Low level method | `String` | `GET`

### Options

it's the second parameter

| Required | Key | Descripiton | Type | Default
| :--- | :--- | :--- | :--- | :---
| yes | `accessToken` | Top level access token | `String` | `""`
| no | `method` | Top level method (`POST` in batch requests always) | `String` | `POST`
| no | `api` | Top level api (`""` in batch requests always) | `String` | `""`
| no | `includeHeaders` | include headers in response or not | `Boolean` | `false`
| no | `appId` | Top level facebook application ID | | `null`
| no | `timeout` | Amount of time between batch requests | `ms` | `60000`
| no | `before` | Before first loop | `Function` | `null`
| no | `after` | After last loop | `Function` | `null`
| no | `beforeEach` | Before each loop | `Function` | `null`
| no | `afterEach` | After each loop | `Function` | `null`
| no | `retry` | Retry canceled requests? | `Boolean` | `true`

## Tests

First of all make sure you have installed dev dependencies:

```
npm install
```

To run tests you should make file at the root folder `facebook.json` and put there expected 
expected by you information that you can get from`Facebook Graph API Explorer`.

```json
{
  "me": {  
    "name": "[FACEBOOK_NAME]",
    "id": "[FACEBOOK_ID]",
    "accessToken": "[FACEBOOK_ACCESS_TOKEN]"
  },
  "page": {
    "accessToken": "[PAGE_FACEBOOK_ACCESS_TOKEN]"
  }
}
```

Then run

```
npm test
```

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