I’m currently building my auth system (yes, from the other post), but I got chained in a Promise.t mess (kinda normal for javascript).
Right now I have this:
fetch(...)
->Promise.then(Response.json)
->Promise.thenResolve(json => {
let val = JSON.Decode.object(json)->Option.getOrThrow
// let user = User.fromJson(val)
Console.log(val)
// TODO: I should set the state to AuthenticatedWithData(user)
})
But I need that AuthenticatedWithData variant in the outer scope, not in the promise scope. I’m inside of a reducer, so I can’t use any react tricks for it, is there anything I can do to fix that?
Or is there any javascript binding I can write to fix that? I’m kinda confused on that.