Commit f9fe9917 authored by nightpool's avatar nightpool Committed by Eugen Rochko

Fallback when no data returned (#89)

When instances.social returns an empty array, try the fallback
parent c9838c77
......@@ -29,7 +29,13 @@ export function fetchInstances() {
}
axios.get('https://instances.social/api/1.0/instances/list', { headers, params })
.then(({ data }) => dispatch(fetchInstancesSuccess(data.instances)))
.then(({ data }) => {
if (data.instances.length == 0) {
throw new Error("No data returned");
}
return dispatch(fetchInstancesSuccess(data.instances));
})
.catch(err => {
console.error(`Using cached fallback for (${params.category}, ${language}) because of: ${err.message}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment