Created
August 9, 2021 01:01
-
-
Save gentilmente/67ab5df0767c486573e7856b8df212ca to your computer and use it in GitHub Desktop.
manage two public APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://apipheny.io/free-api/ | |
const fetch = require("node-fetch"); | |
const text = fetch("https://catfact.ninja/fact") | |
.then((res) => res.json()) | |
.then((json) => { | |
const text = json.fact; | |
console.log(text + "\n"); | |
fetch("https://libretranslate.de/translate", { | |
method: "POST", | |
body: JSON.stringify({ | |
q: text, | |
source: "en", | |
target: "es", | |
}), | |
headers: { "Content-Type": "application/json" }, | |
}) | |
.then((res) => res.json()) | |
.then((json) => console.log(json.translatedText)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment