Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import https from 'https';
import config from '../../config.json';

export const getProjects = async () => {
Expand All @@ -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.',
};
}
};