Created
June 3, 2023 09:18
-
-
Save liketaurus/95eb38fdf920e846f32ca113b8ba4e8b to your computer and use it in GitHub Desktop.
How to get horoscope for today for specified zodiac sign for free
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
sync function getHoroscope(sign) { | |
const url = `https://horoscopes-ai.p.rapidapi.com/get_horoscope/${sign}/today/general/en`; | |
const options = { | |
method: 'GET', | |
headers: { | |
'X-RapidAPI-Key': 'YOUR_HOROSCOPE_AI_API_KEY(details_at_https://docs.rapidapi.com/docs/keys)', | |
'X-RapidAPI-Host': 'horoscopes-ai.p.rapidapi.com' | |
} | |
}; | |
try { | |
const response = await fetch(url, options); | |
const result = await response.text(); | |
console.log(result); | |
const horo = JSON.parse(result); | |
document.getElementById("horoscope").innerHTML = `Horoscope: ${horo.general}`; | |
} catch (error) { | |
console.error(error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment