Explorer

definy.sync-response-json

description
The JSON body of a successful RPC response
type
Fn(response: @definy.service-response) -> Union{#ok(@definy.json), #error(String)}
expression
fn(response$0) =>
  match @core.equal(left: $0.status, right: 200) {
    true =>
      match $0.body {
        #json(json$1) =>
          #ok($1),
        _ =>
          #error(@core.string-concat(left: "unexpected response: ", right: @definy.http-body-text(body: $0.body)))
      },
    false =>
      #error(@std.string-join(
        items: ["status ", @std.number-to-string(value: $0.status), ": ", @definy.http-body-text(body: $0.body)],
        separator: ""
      ))
  }
visibility
public
definy.sync-response-json (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: BNQyVoVAV_8gFksqeSH0WgUvX0LZzMQADU8WPefC_VY
content hash: xwxrmR9Gzv2nbBEdoTiGfruiGLqUJ42ACAGioLmgzmE