Skip to content

Implement an ok boolean to signal whether an API request was successful. #904

Description

@LiranCohen

Currently the various DwnApi responses return a DwnResponseStatus object which includes a code and `detail.

It would be helpful to follow a similar pattern as the fetch API to additionally return an ok boolean that determines if the request is considered successful or not. This reduces the overhead for developers to think about which status codes are relevant for which response, and only utilize those codes when they need to act on them.

It's useful to understand the different codes that dwn-sdk-js throws for the various method handlers, for example RecordsWrite can return:

  • 202 - Successful write.
  • 204 - Write was accepted, but no content is assigned to the record, a query/read would not return a result.
  • 409 - Conflict, a newer or equivalent record already exists, write failed.
  • 400 - Message validation error
  • 401 - Authorization error

I would expect that only a 202 of this list would be considered a successful result to the caller.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions