Skip to content

Instantly share code, notes, and snippets.

@skflowne
Last active August 14, 2020 13:48
Show Gist options
  • Save skflowne/ca42b42e9d487b29b53d7597246ad440 to your computer and use it in GitHub Desktop.
Save skflowne/ca42b42e9d487b29b53d7597246ad440 to your computer and use it in GitHub Desktop.
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