This is a TypeScript/JavaScript wrapper for the Deez Nuts Jokes API. The original repo for the API can be found at DNJokes-API, also available on RapidAPI.
Install DNJokes-API Wrapper with npm
npm i dnjokes-api-wrapper
or with yarn
yarn add dnjokes-api-wrapper
or use as an inline script with a CDN
<script src="https://cdn.jsdelivr.net/npm/dnjokes-api-wrapper/lib/cjs/index.min.js"></script>
To use the wrapper, you need to import it into your project.
ESM Module
import getAllDNJokes from 'DNJokes-API-Wrapper';
getAllDNJokes().then((res) => {
console.log(res);
});
CommonJS
const DNJokes = require('DNJokes-API-Wrapper');
DNJokes.getAllDNJokes().then((res) => {
console.log(res);
});
These are the commands you can use with the wrapper
// Get an array of all jokes in the database
getAllDNJokes(max_results: number); // putting a value in the function will define the maximum number of jokes to return
// Get a random joke from the database
getRandomDNJoke();
// Get a joke by ID
getDNJokeById(dn_id: number); // put the ID of the joke you want to get in the function
// Get a joke by search query
getDNJokeByQuery(keyword: string); // put the search query in the function
To run tests, run the following command
npm test
Contributions are always welcome! Open an issue with any issues or requests!
Distributed under the MIT License. See LICENSE.md
for more information.