Skip to content

Instantly share code, notes, and snippets.

@drejohnson
Last active October 23, 2018 13:15
Show Gist options
  • Save drejohnson/18bd952494561fa103fa465923bc28b7 to your computer and use it in GitHub Desktop.
Save drejohnson/18bd952494561fa103fa465923bc28b7 to your computer and use it in GitHub Desktop.
/* Using jaredly/let-anything */
module Await = {
let let_ = (promise, continuation) =>
promise
|> Js.Promise.then_(value => continuation(value) |> Js.Promise.resolve);
};
let fetchAsync = {
let%Await response = Fetch.fetch("https://swapi.co/api/films/1/");
let%Await data = response->json() |> Js.Promise.resolve;
Js.log(data);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment