Current section
Files
Jump to
Current section
Files
src/internal/http/response.gleam
import decode.{type Decoder}
import gleam/http/response.{type Response}
import gleam/json
import gleam/result
import internal/http/error.{DecodeError}
pub fn decode(response: Response(String), using decoder: Decoder(t)) {
response.body
|> json.decode(using: decode.from(decoder, _))
|> result.replace_error(DecodeError)
}