10 examples of 'http-status-codes npm' in JavaScript

Every line of 'http-status-codes npm' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
9setStatus(code: number): Response {
10 this.express.status(code);
11 return this;
12}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

31set statusCode(code) {
32 code = parseInt(code)
33 if (!code) {
34 throw new Error('invalid status code') // TODO: test this
35 }
36 this._setRawDataItem('statusCode', code)
37}
19function status(response) {
20 // Assume opaque responses are cool, because who knows?
21 return response.type === "opaque" || (response.status >= 200 && response.status < 300);
22}
33function status(response) {
34 if (response.status >= 200 && response.status < 300) {
35 return Promise.resolve(response);
36 } else {
37 return Promise.reject(new Error(response.statusText));
38 }
39}
12public get status (): number {
13 return Response.toHttpStatus(this.responseCode);
14}
62isSuccessCode (code) {
63 return parseInt(code, 10) >= 100 && parseInt(code, 10) <= 399
64}
19status(statusCode) {
20 this.statusCode = statusCode;
21 return this;
22}
2function status(response) {
3 if (response.status >= 200 && response.status < 300) {
4 return Promise.resolve(response);
5 }
6 else {
7 return Promise.reject(new Error(response.statusText));
8 }
9}
177function isErrorStatus(status) {
178 return [401, 403, 404, 412].indexOf(status) >= 0;
179}
365static code() {
366 return status.GONE;
367}

Related snippets