mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 21:46:20 +00:00
Ensured default servers is validated as JSON and ignored otherwise
This commit is contained in:
@@ -31,9 +31,10 @@ export const listServers = ({ listServers, createServers }, { get }) => () => as
|
||||
}
|
||||
|
||||
// If local list is empty, try to fetch it remotely and calculate IDs for every server
|
||||
// It's important to parse the content to json, so that it is ignored for other formats (because it will catch)
|
||||
const getDataAsJsonWithIds = pipe(prop('data'), JSON.parse, map(assocId));
|
||||
const remoteList = await get(`${homepage}/servers.json`)
|
||||
.then(prop('data'))
|
||||
.then(map(assocId))
|
||||
.then(getDataAsJsonWithIds)
|
||||
.catch(() => []);
|
||||
|
||||
createServers(remoteList);
|
||||
|
||||
Reference in New Issue
Block a user