{"id":13756631,"url":"https://github.com/xixilive/weapp-next","last_synced_at":"2026-04-03T14:03:21.776Z","repository":{"id":52145058,"uuid":"77467988","full_name":"xixilive/weapp-next","owner":"xixilive","description":"Wechat applet(微信小程序) official API wrapper, purpose to expose fashionable, friendly and fluent programming API.","archived":false,"fork":false,"pushed_at":"2022-12-06T19:15:03.000Z","size":607,"stargazers_count":84,"open_issues_count":3,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-12T22:04:08.359Z","etag":null,"topics":["weapp","weapp-es6","wechat","weixin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xixilive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-27T16:20:36.000Z","updated_at":"2024-10-20T09:35:35.000Z","dependencies_parsed_at":"2023-01-23T12:15:24.802Z","dependency_job_id":null,"html_url":"https://github.com/xixilive/weapp-next","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/xixilive/weapp-next","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Fweapp-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Fweapp-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Fweapp-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Fweapp-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xixilive","download_url":"https://codeload.github.com/xixilive/weapp-next/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xixilive%2Fweapp-next/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31355722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["weapp","weapp-es6","wechat","weixin"],"created_at":"2024-08-03T11:00:49.718Z","updated_at":"2026-04-03T14:03:21.740Z","avatar_url":"https://github.com/xixilive.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# weapp-next\n\nWeapp(微信小程序) official API wrapper, purpose to expose fashionable, friendly and fluent programming API.\n\n[![Build Status](https://travis-ci.org/xixilive/weapp-next.svg?branch=master)](https://travis-ci.org/xixilive/weapp-next)\n\n![weapp-screen-shot](./docs/screen-shot.png)\n\n## Features\n\n- Promisified async API\n\n- Shortcuts for `wx.request` API\n\n- Enhancements official APIs\n\n- RESTful http client\n\n## Install\n\n```\n# via Github\nnpm i xixilive/weapp-next --save-dev\n```\n\n```\n# via npm\nnpm i weapp-next --save-dev\n```\n\n## Examples\n\n### non-callback and RESTful HTTP\n\n```js\nconst weapp = require('weapp-next')(wx)\nconst client = weapp.Http('https://api.server.com/')\n\n//async/await\nasync function postLogin(){\n  const {code} = await weapp.login()\n  const {errMsg, ...userInfo} = await weapp.getUserInfo({withCredentials: true})\n  return await client.post('/login', {data: {...userInfo, code}})\n}\n\n//promise\nfunction postLogin(){\n  const getUserInfo = code =\u003e opts =\u003e {\n    return weapp.getUserInfo(opts).then(({errMsg, ...userInfo}) =\u003e ({userInfo, code})\n  }\n\n  const postRequest = data =\u003e client.post('/login', {data})\n  return weapp.login().then(getUserInfo).then(postRequest)\n}\n```\n\n## Usage\n\n`weapp-next` use UMD module system, you can load it in Commonjs or AMD format.\n\n```js\nimport weapp from 'weapp-next'\n\n// get wrapped wx Object\nconst {request, Http} = weapp(wx)\n\n// use request API\nrequest({url: 'https://test.com', method: 'GET'}).then(response =\u003e console.log)\n\n// use shortcuts of request API, such as get, post, put, etc.\nrequest.get('https://test.com').then(response =\u003e console.log)\n\n// use Http client\nconst http = Http('https://server.com/api')\nhttp.get('/path').then(response =\u003e console.log)\n\n// or\nconst weapp = require('weapp-next')(wx)\n```\n\nWraps almost all of official APIs, see [Wrapped methods](./docs/METHODS.md)\n\n## Enhancements\n\nCreate http request shortcuts according to wechat mini-program declared verbs(RFC 2616). specially, the `PATCH` verb maybe useful for strict RESTful-ist, and so it has defined also.\n\n### `weapp.request`\n\nIt resolves a response which take a statusCode in range of [200, 300), and reject a response which out of the range.\n\nThe resolved response and rejected reason/error is the response object from the native `wx.request`.\n\n```js\nimport weapp from 'weapp-next'\nconst {request} = weapp(wx)\n\nrequest({url, method: 'GET'})\n  .then(response =\u003e {\n    // response is the response object from wx.request\n  })\n  .catch(error =\u003e {\n    // error is the response object from wx.request\n  })\n\nrequest.get(url:String [, init:Function])\nrequest.post(url:String, body:String/Object, [, init:Function])\nrequest.put(url:String, body:String/Object, [, init:Function])\nrequest.patch(url:String, body:String/Object, [, init:Function])\nrequest.delete(url:String [, init:Function])\nrequest.head(url:String [, init:Function])\nrequest.options(url:String [, init:Function])\nrequest.trace(url:String [, init:Function])\nrequest.connect(url:String [, init:Function])\n```\n\nOptional `init` argument is a zero-arugments function to interpolate request parameters, and it expects to return an Object value by contract. you can override any request params by the returned object except the `url` and `method`.\n\n```js\n// logic of init function\nconst config = {...}\nreturn {...config, ...init(), url, method}\n```\n\n### `weapp.requireAuth` (DPRECIATED)\n\n\u003e DPRECIATED\n\nHere is a Express middleware for weapp login scenario which purpose to make it easy to integrate weapp login and getUserInfo logic. [express-weapp-auth](https://github.com/xixilive/express-weapp-auth)\n\n## Use RESTful Http client\n\n```js\nimport weapp from 'weapp-next'\n\nconst http = weapp(wx).Http('https://api.server.com/')\nhttp.get('/status', {version: '1'}) // /status?version=1\nhttp.post('/status', {data: {}})\n```\n\n## Changes\n\n[Change log](./CHANGELOG.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxixilive%2Fweapp-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxixilive%2Fweapp-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxixilive%2Fweapp-next/lists"}