Hi!
I have the following code:
type authResponse = {
"access_token": string,
"expires_in": int,
"id_token": string,
"refresh_token": string,
"scope": string,
"token_type": string,
}
type auth = {loginUsername: (string, string) => Js.Promise.t<authResponse>}
@module("@patient/data-sdk") external auth: auth = "auth"
auth.loginUsername("foo", "Bar")->Js.Promise.then_(value => {
Dom_storage.setItem("session", Js.Json.stringify(value), Dom_storage.localStorage)
Js.Promise.resolve(value)
}, _)->ignore
It fails saying that:
109 ┆ auth.loginUsername(username, password)
110 ┆ ->Js.Promise.then_(
111 ┆ value => {
This has type:
Js.Promise.t<authResponse> (defined as Js_promise.t<authResponse>)
Somewhere wanted:
Js.Promise.t<Js.Json.t> (defined as Js_promise.t<Js.Json.t>)
The incompatible parts:
authResponse (defined as
{
"access_token": string,
"expires_in": int,
"id_token": string,
"refresh_token": string,
"scope": string,
"token_type": string
,})
vs Js.Json.t (defined as Js_json.t)
Playground link
It seems that using Js.Json.stringify
mutates the value, How else can I do this?
I can’t find any information about this or probably don’t know how to look for it.
Any help is deeply apreciated, been trying to fix it for some time and I am very frustrated at this moment.