Closed aaron-michaux closed 6 years ago
@aaron-michaux the example is working, but you're using it in didMount
method which should return unit
not Js.Promise.t(unit)
. So you should do something like this:
didMount: (_self) => {
Js.Promise.(
Axios.get("/user?ID=12345")
|> then_((response) => resolve(Js.log(response##data)))
|> catch((error) => resolve(Js.log(error)))
);
();
}
()
(unit
) obviously. Or you can use standard OCaml function ignore
which return unit
for any type of parameter passed:
didMount: (_self) => {
Js.Promise.(
Axios.get("/user?ID=12345")
|> then_((response) => resolve(Js.log(response##data)))
|> catch((error) => resolve(Js.log(error)))
|> ignore
);
}
`
25 │ didMount: (self) => 26 │ 27 │ Js.Promise.( 28 │ Axios.get("/user?ID=12345") 29 │ |> then((response) => resolve(Js.log(response##data))) 30 │ |> catch((error) => resolve(Js.log(error))) 31 │ ), 32 │
33 │ / Js.Promise.( /
This has type: Js.Promise.t(unit) (defined as Js.Promise.t(unit)) But somewhere wanted: unit `
My
bsconfig.json
contains axios:"bs-dependencies": [ "reason-react", "bs-jest", "bs-axios", "bs-css" ]