I am reading this tutorial https://www.stackbuilders.com/blog/nonsense-getting-started-with-reason-and-reason-react/. One of the problems I am facing is that api.noopschallenge.com
is now dead. I replaced the API call to this https://random-word-api.herokuapp.com/word?number=20
This works but returns a Json Array. I have to convert the Json Array to list(string).
I modified the decodeWords
function as
let decodeWord = (json: Js.Json.t) : list(string) =>
switch(Js.Json.decodeArray(json)) {
| None => []
| Some(array) => Belt.Array.map(Js.Json.decodeString, array)
};
But this gives me error
This has type: Js.Json.t => option(Js.String.t) But somewhere wanted: array('a)
How do I convert the Json Array to list(string)
?