diff --git a/src/utils/api.ts b/src/utils/api.ts index 6840cac..248a524 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import https from 'https'; import config from '../../config.json'; export const getProjects = async () => { @@ -23,8 +24,18 @@ export const getWeather = async (city: string) => { }; export const getQuote = async () => { - const { data } = await axios.get('https://api.quotable.io/random'); - return { - quote: `“${data.content}” — ${data.author}`, - }; + try { + const agent = new https.Agent({ + rejectUnauthorized: false, // Disable SSL verification + }); + const { data } = await axios.get('https://api.quotable.io/random', { httpsAgent: agent }); + return { + quote: `“${data.content}” — ${data.author}`, + }; + } catch (error) { + return { + quote: 'Unable to fetch a quote at the moment. Please try again later.', + }; + } }; +