We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As an example, this is was I used in my app at work.
type FetchResult = | Success of Response | BadStatus of Response | NetworkError let fetch (url: string) (init: RequestProperties list) : JS.Promise<FetchResult> = GlobalFetch.fetch(RequestInfo.Url url, Fetch.requestProps init) |> Promise.map (fun response -> if response.Ok then Success response else if response.Status < 200 || response.Status >= 300 then BadStatus response else NetworkError ) let postRecord (url: string) (body: string) (properties: RequestProperties list) = let defaultProps = [ RequestProperties.Method HttpMethod.POST Fetch.requestHeaders [ ContentType "application/json" ] RequestProperties.Body !^(body) ] List.append defaultProps properties |> fetch url |> Promise.bind(fun result -> promise { match result with | Success response -> return response | BadStatus response -> return failwith (string response.Status + " " + response.StatusText + " for URL " + response.Url) | NetworkError -> return failwith "network error" } )
The idea is that it's important to give access to the user to Response so he doesn't lose information about what happened.
Response
We have to provide a Result<_, _> version of the "safe" requests (tryXXXX) and one which uses exceptions for the "unsafe" requests.
Result<_, _>
tryXXXX
The text was updated successfully, but these errors were encountered:
Error reports - fixes thoth-org#7
f8fd78a
No branches or pull requests
As an example, this is was I used in my app at work.
The idea is that it's important to give access to the user to
Response
so he doesn't lose information about what happened.We have to provide a
Result<_, _>
version of the "safe" requests (tryXXXX
) and one which uses exceptions for the "unsafe" requests.The text was updated successfully, but these errors were encountered: