This module extends the Http module with better error handling and more information in the success case.
Named type alias for the Http.task parameter
Convenience function to convert an Ext.Http.Error to a String.
When http succeeds, you get a Data record with both the Http.Metadata and the data that was decoded from the response.
Http.task request
|> Task.andThen
(\{ meta, data } ->
-- do something with meta and/or data
-- like checking the status code
)Useful for non-json payloads like Bytes or String
A resolver that does not process the response at all. It just returns the response as-is, but with Http.Metadata included. And with error type as Ext.Http.Error instead of Http.Error.
Resolver for Http.task that includes proper details in both the error case and metadata in the success case.
Usually metadata is not needed in the success case, just add Task.map .data to your existing code
```diff
Http.task
{ method = "GET"
, headers = []
, url = "https://example.com"
, body = Http.emptyBody
- , resolver = Http.stringResolver (otherJsonResolver myDecoder)
+ , resolver = Http.stringResolver (Ext.Http.jsonResolver myDecoder)
, timeout = Nothing
}
+ |> Task.map .data
```But when you need it, having the metadata available is very useful.
```diff
Http.task
{ method = "GET"
, headers = []
, url = "https://example.com"
, body = Http.emptyBody
, resolver = Http.stringResolver (Ext.Http.jsonResolver myDecoder)
, timeout = Nothing
}
+ |> Task.map (Debug.log "{ meta, data }")
|> Task.map .data
```
Use Ext.Http.Error instead of Http.Error to get more information about the error.