6 examples of 'express status code' in JavaScript

Every line of 'express status code' 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
9public setStatusCode(code: number): IResponse {
10 this.res.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

49public set statusCode(value: number | undefined) {
50 this.ensureHeadersNotSent();
51
52 this.innerStatusCode = value;
53
54 if (value) {
55 this.response.statusCode = value;
56 }
57}
62isSuccessCode (code) {
63 return parseInt(code, 10) >= 100 && parseInt(code, 10) <= 399
64}
9setStatus(code: number): Response {
10 this.express.status(code);
11 return this;
12}
36function checkCode (res) {
37 // 如果code异常(这里已经包括网络错误,服务器错误,后端抛出的错误),可以弹出一个错误提示,告诉用户
38 if (res.status === -404) {
39 // console.log(res.msg)
40 }
41 if (res.data && (!res.data.success)) {
42 // console.log(res)
43 // console.log(res.data.msg)
44 }
45 return res
46}
18function getErrorStatus(code?: string): number {
19 if (!code) {
20 return 500;
21 }
22
23 // $FlowFixMe: Flow doesn't like accessing a map with a generic string
24 const statusNumber = errorCodeToStatus[code];
25 return statusNumber || 500;
26}

Related snippets