Comparing version 1.0.1 to 2.0.0
# Changelog | ||
## Version 2.0.0 (Major Updates) - [25-03-2024] | ||
-Features Added: | ||
--Implemented icanhazdadjoke function to retrieve jokes from the icanhazdadjoke API. | ||
Users can now access jokes from the icanhazdadjoke API using the icanhazdadjoke function. | ||
-Changes: | ||
--Removed all previous code implementations. | ||
--Replaced previous functionalities with the icanhazdadjoke function to streamline joke retrieval. | ||
## Version 1.0.1 (pkg fix) - [25-03-2024] | ||
@@ -4,0 +14,0 @@ - Changed Github Repository |
45
index.js
@@ -1,17 +0,34 @@ | ||
var mrng= require('mrng'); | ||
var mrng = require("mrng"); | ||
var links = require("./assets/links"); | ||
async function random_facts(){ | ||
var random = mrng(1,1000) | ||
var komedy = "" | ||
await fetch('https://api.chucknorris.io/jokes/random') | ||
.then(response => response.json()) | ||
.then(data => { | ||
komedy = data.value; | ||
// console.log(chuckNorrisJoke); | ||
}) | ||
.catch(error => komedy="Error"); | ||
const dads_jokes = { | ||
return `${random}=> ${komedy}` | ||
} | ||
// 1 | ||
async icanhazdadjoke() { | ||
try { | ||
const response = await fetch(links.icanhazdadjoke, { | ||
headers: { | ||
Accept: "application/json", | ||
}, | ||
}); | ||
module.exports = random_facts; | ||
if (!response.ok) { | ||
if (response.status === 404) { | ||
throw new Error("Joke not found"); | ||
} else { | ||
throw new Error("Network error"); | ||
} | ||
} | ||
const data = await response.json(); | ||
return data.joke; | ||
} catch (error) { | ||
return error.message; | ||
} | ||
}, | ||
}; | ||
module.exports = dads_jokes; |
{ | ||
"name": "dads_jokes", | ||
"version": "1.0.1", | ||
"description": "A library to get a random fact.", | ||
"version": "2.0.0", | ||
"description": "dads_jokes Library is a lightweight JavaScript library designed to fetch dad jokes from open APIs", | ||
"main": "index.js", | ||
@@ -17,5 +17,5 @@ "scripts": { | ||
"keywords": [ | ||
"random-facts", | ||
"random", | ||
"facts" | ||
"dads_jokes", | ||
"jokes", | ||
"lame_jokes" | ||
], | ||
@@ -25,5 +25,5 @@ "author": "Imtiyaz Ali", | ||
"bugs": { | ||
"url": "https://github.com/Imtiyaz-ali/random_facts_generator/issues" | ||
"url": "https://github.com/Imtiyaz-ali/dads_jokes/issues" | ||
}, | ||
"homepage": "https://github.com/Imtiyaz-ali/random_facts_generator#readme" | ||
"homepage": "https://github.com/Imtiyaz-ali/dads_jokes#readme" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3468
6
29