Hi, bs-fetch is the original Fetch API. It’s a package containing bindings, like the one you wrote by hand. One issue with your binding is that it’s not type-safe–the return type Js.Promise.t<'a> is too broad for the actual type, which is JSON. The return type should be Js.Promise.t<Js.Json.t>.
Decoding can be done with a library like Decco, which basically provides a macro that looks at the structure of a type definition and generates a decoder for it.
In ReScript, the way you safely handle an external “any” type is to give it an opaque/abstract type and then use a function at runtime to safely cast it to the correct type. In fact, this is exactly what the Js.Json.t type is, and exactly what Decco does (along with other JSON decoding libraries). Js.Json.t essentially mean “any type that conforms to the JSON spec.”
Probably would have been better to start a new thread after 2 years: with additional infos on what you are trying to achieve and a code-snippet of the code having the described error.
This way it would be easier to help.
But the shortest possible reprosucible code with your described error is this:
let x =
The error states, you forgot to define ,what the actual value (expression) of a let binding should be.
You could fix the example above by adding the missing part: