New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ntbl/api

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ntbl/api

用于处理后端接口的适配器。内置了过滤,拼接查询字符和添加时间戳的插件, 并提供了自定义插件的功能。

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
2
Weekly downloads
 
Created
Source

api

gitHub Version License

用于处理后端接口的适配器。内置了过滤,拼接查询字符和添加时间戳的插件, 并提供了自定义插件的功能。

Api Documentation

Installation

npm i @ntbl/api --save

Usage

import Api from '@ntbl/api'

// 插件
const {QUERY, TIMESTAMP, FILTER} = Api
// 把 maps 接口映射对象,
// app 依赖的 ajax 库(目前,只测试了 axios)
// 和插件传入,
// 并实例化,调用 export() 方法
const api = Api(maps, app, QUERY, TIMESTAMP, FILTER)
// 调用接口
api('login', data)
 .then(res => {})
 .catch(err =>{})
  • FILTER - 过滤器。
  • QUERY - 拼接 get 请求的查询字符串。
  • TIMESTAMP - 为 get 请求添加时间戳,以避免请求数据被缓存。
const maps = {
  // 标准写法,请求方法默认为 get
  userDetail: '/user/detail',
  // 同上
  userDetail: {
     method: 'get',  // 可省略,默认为 get
     url: '/user/detail'
  },

  // post 的简写
  'login@': '/user/login',
  // 或者显式指定
  'login@post': '/user/login'

  // 其他请求方法
  'userUpdate@put': '/user/update'

  // 当启用 FILTER 插件后,支持过滤数据
  'register@': {
    url: '/user/register',
    only: ['username', 'password'],
    // 或者
    only: 'username password'
  }
}

Keywords

FAQs

Package last updated on 07 May 2019

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