Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: add failOnStatusCode to requestContext #34204

Open
fdm-mateco opened this issue Jan 3, 2025 · 0 comments
Open

[Feature]: add failOnStatusCode to requestContext #34204

fdm-mateco opened this issue Jan 3, 2025 · 0 comments

Comments

@fdm-mateco
Copy link

fdm-mateco commented Jan 3, 2025

🚀 Feature Request

When defining a (manual) API request context, one should be able to define failOnStatusCode. This should cause all requests done through this context to apply the flag (unless overridden).

const context = await request.newContext({
      baseURL: 'https://example/api/',
      extraHTTPHeaders: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${process.env.TOKEN}`,
      },
      failOnStatusCode: true
    });

Example

No response

Motivation

It will prevent repetitive code, as we'll no longer have to add the property on every API call as is now:

await this.context.get('contactpersons', { failOnStatusCode: true });
await this.context.get('addresses', { failOnStatusCode: true });
await this.context.get('customers', { failOnStatusCode: true });
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

No branches or pull requests

1 participant