# dadjokes-wrapper

![Travis](https://img.shields.io/travis/Neos-Duswell/dadjokes-wrapper.svg)
![npm](https://img.shields.io/npm/v/npm.svg)
![npm](https://img.shields.io/npm/dw/dadjokes-wrapper.svg)

> NodeJS wrapper for the ICanHazDadJokes API

This module will help you to get some nice Dad Jokes !

## Usage

```js
const DadJokes = require('dadjokes-wrapper');
const dj = new Dadjokes();

dj.randomJoke()
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

exemple of output

```
Two guys walked into a bar, the third one ducked.
```

## API

```js
const DadJokes = require('dadjokes-wrapper');
const dj = new Dadjokes();

dj.randomJoke()
  .then(res => console.log(res))
  .catch(err => console.error(err));
// Returns a random joke

dj.randomSlackJoke()
  .then(res => console.log(res))
  .catch(err => console.error(err));
// Returns a random joke formatted for slack

dj.jokeById('R7UfaahVfFd') 
  .then(res => console.log(res))
  .catch(err => console.error(err));
// This method is auto-cached and returns a joke by it's id

dj.jokeImgById('gNu41gNeqjb')
  .then(res => res)
  .catch(err => console.error(err)); 
// Returns an image of the joke

dj.searchJoke()
  .then(res => console.log(res))
  .catch(err => console.error(err));
// Look here for the query parameters available
// https://icanhazdadjoke.com/api#search-for-dad-jokes
```

## Install

With [npm](https://npmjs.org/) installed, run

```
$ npm install dadjokes-wrapper
```

Or with [yarn](https://yarnpkg.com/en/) installed, run

```
$ yarn add dadjokes-wrapper
```

## See Also

- [`noffle/common-readme`](https://github.com/noffle/common-readme)
- [`ICanHasDadJoke API`](https://icanhazdadjoke.com/api)

## License

MIT

