Skip to content

lany9527/wx-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

微信小程序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) {
        // ...
      });

About

webSocket for weChat app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published