1.0.4 • Published 7 years ago

wx-resource v1.0.4

Weekly downloads
5
License
ISC
Repository
github
Last release
7 years ago

微信小程序webSocket模拟http请求

使用

安装

    npm install wx-resource

用法示例

// token为 非必传参数
// 需要服务器配合解析由websocket 传过去的data
import WxResource from 'wx-resource'
 
 const wxResource = new WxResource("ws://..."); //websocket 地址
 
 wxResource.get(
       'http://...',
       token
     ).then(function (res) {
       // ...
     });
wxResource.post(
       'http://...',
       {          
         data: {
           x: y,
           y: y
         }
       },
       token
     ).then(function (res) {
       // ...
     });
 wxResource.delete(
        'http://...',
        {
          data: {
            x: y,
            y: y
          }
        },
        token
      ).then(function (res) {
        // ...
      });
wxResource.update(
        'http://...',
        {
          data: {
            x: y,
            y: y
          }
        },
        token
      ).then(function (res) {
        // ...
      });
1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago