Skip to content

Conversation

m1212e
Copy link

@m1212e m1212e commented Feb 24, 2025

This option allows for simple usage of the treaty client. It offers a shouldThrow in the config which makes the client throw in case of an error instead of returning the whole response object.

This reduces the boilerplate in environments where throwing is desired and simplifies the response handling:

const userResult = await backend.auth["upsert-self"].post();
if (userResult.error) {
  throw userResult.error;
}
const user = userResult.data;

// becomes
const user = await backend.auth["upsert-self"].post();

This way the users can decide how the client should behave per default.
Let me hear what you think!

@kravetsone
Copy link

maybe just throw?

@m1212e
Copy link
Author

m1212e commented Feb 24, 2025

You mean the field name of the config option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants