Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xyj-res

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xyj-res

res

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

#xyj-res ##install npm install xyj-res ##usage

const express = require('express');
const xRes = require('xyj-res');
let app = new express();
app.use(xRes);

##res.api

res.api('请求成功这是响应');

####客户端收到的响应

{"data":"请求成功这是响应","status":{"code":0,"msg":"request success"}}

##res.error

let data = {
    code: 10001,
    msg: 'test error',
    data: '可选',
}//服务器自定义错误代码和描述
res.error(data);
//res.error(); //如果不传入status,则会默认返回{"code":99999,"msg":"system error"}

####客户端收到的响应

{"data":"这是一个错误","status":{"code":10001,"msg":"test error"}}
//{"data":"这是一个错误","status":{"code":99999,"msg":"system error"}} 

Keywords

FAQs

Package last updated on 18 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc