Last active
August 14, 2020 13:48
-
-
Save skflowne/ca42b42e9d487b29b53d7597246ad440 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { selector } from "recoil" | |
export const countriesQuery = selector({ | |
key: "countries", | |
get: async () => { | |
try { | |
const res = await fetch("https://covid19-api.org/api/countries") | |
const countries = await res.json() | |
return countries.reduce((dict, country) => { | |
dict[country.alpha2] = country | |
return dict | |
}, {}) | |
} catch (e) { | |
console.error("ERROR GET /countries", e) | |
} | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment