Socket
Book a DemoInstallSign in
Socket

promise-success

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-success

this is a encapsulation based on urllib, it only call Fulfilled when the status === 200

2.0.3
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

promise-success

目标:封装公司现有请求:

请求返回200:resolve,附带经过JSON.parse()后的数据。

其他情况一律:reject,并附带JSON.parse()后的数据(如果有的话)和请求的 statusCode。

Install

$ npm install promise-success --save

Usage


'use strict';

var koa = require('koa');
var app = koa();
var request = require('promise-success');

app.use(function *(){
  try {
    var result = yield request('https://www.baidu.com');
    this.body = result;
  } catch (e) {
    this.body = e;
  }
});

app.listen(8000);


Keywords

urllib

FAQs

Package last updated on 16 May 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.