Skip to content

Commit

Permalink
Increase resiliance against failing apis
Browse files Browse the repository at this point in the history
- Sanity is failing with request timeouts and we are failing as a result
  • Loading branch information
henrikhorluck committed Nov 3, 2024
1 parent 5c69e50 commit b2cc2d4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/frontpage/api/offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ const API_URL =
'https://wsqi2mae.api.sanity.io/v1/data/query/production?query=*%5B_type%3D%3D%22offline%22%5D%20%7C%20order(release_date%20desc)%20%7B%0A%20%20_id%2C%0A%20%20title%2C%0A%20%20release_date%2C%0A%20%20%22issue%22%3A%20pdf.asset%20-%3E%20url%2C%0A%20%20%22image%22%3A%20thumbnail.asset%20-%3E%20%7B%0A%20%20%20%20url%2C%0A%20%20%20%20title%0A%20%20%7D%0A%7D';

export const getAllOfflines = async (): Promise<IOfflineIssue[]> => {
const res = await fetch(API_URL, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
const data = await res.json();
return data.result as IOfflineIssue[];
try {
const res = await fetch(API_URL, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
const data = await res.json();
return data.result as IOfflineIssue[];
} catch (error) {
console.error('Error fetching data:', error);
return [];
}
};

0 comments on commit b2cc2d4

Please sign in to comment.