Skip to content

Instantly share code, notes, and snippets.

@dardub
Last active January 17, 2018 00:54
Show Gist options
  • Save dardub/202f013835a8d66cee904650e2b8754f to your computer and use it in GitHub Desktop.
Save dardub/202f013835a8d66cee904650e2b8754f to your computer and use it in GitHub Desktop.
Hello World
type messageBody = {
  message: string,
  input: string
};

type response = {
  statusCode: int,
  body: Js.Json.t
};

let hello = (event, context, callback) => {
  let body : messageBody = {
    message: "Hello World!",
    input: event,
  };

  let response : response = {
    statusCode: 200,
    body: Js.Json.stringify(body)
  };

  callback(null, response);
}
@dardub
Copy link
Author

dardub commented Jan 17, 2018

I get the following compiler error (Line 19):


  17 ┆ let response : response = {
  18 ┆   statusCode: 200,
  19 ┆   body: Js.Json.stringify(body)
  20 ┆ };
  21 ┆

  This has type:
    messageBody
  But somewhere wanted:
    Js.Json.t (defined as Js.Json.t)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment