Skip to content

Instantly share code, notes, and snippets.

@liketaurus
Created June 3, 2023 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liketaurus/95eb38fdf920e846f32ca113b8ba4e8b to your computer and use it in GitHub Desktop.
Save liketaurus/95eb38fdf920e846f32ca113b8ba4e8b to your computer and use it in GitHub Desktop.
How to get horoscope for today for specified zodiac sign for free
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