Skip to content

Instantly share code, notes, and snippets.

@odoe
Created April 19, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odoe/3c7309e0310ce2cd2f0b80c38cf122ba to your computer and use it in GitHub Desktop.
Save odoe/3c7309e0310ce2cd2f0b80c38cf122ba to your computer and use it in GitHub Desktop.
const fetchItems = commandFactory<Item>(async ({ path }) => {
const response = await fetch("https://swapi.co/api/");
const json = await response.json();
const items: Item[] = Object.keys(json).map(key => {
return {
label: key,
value: json[key]
};
});
return [replace(path("items"), items)];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment