Skip to content

Commit

Permalink
perf: Improve fetching (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
DestroyerV authored Aug 16, 2024
2 parents 27f3920 + 79d25e7 commit 899465c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/services/fetchFromAPI.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import axios from "axios";

const Base_URL = "https://pipedapi.kavin.rocks";
const urls = [
"https://pipedapi.kavin.rocks",
"https://pipedapi-libre.kavin.rocks",
];
const options = {
params: {
region: 'IN',
maxResults: '50',
region: "IN",
maxResults: "50",
},
};

export const fetchFromAPI = async (url) => {
const { data } = await axios.get(`${Base_URL}/${url}`, options);
const fetchPromises = urls.map((u) => axios.get(`${u}/${url}`, options));
const { data } = await Promise.any(fetchPromises);
return data;
};

0 comments on commit 899465c

Please sign in to comment.