Node SDK for yuque
npm i @yuque/sdk --saveconstSDK=require('@yuque/sdk');constclient=newSDK({token: '<YOUR TOKEN>',// other options});constresult=awaitclient.users.get();console.log(result);// apisconst{ users, groups, repos, docs }=client;/** * @param {Object} options - opts * @param {String} options.token - yuque token, https://www.yuque.com/settings/tokens * @param {String} [options.endpoint] - yuque endpoint * @param {String} [options.userAgent] - request user-agent * @param {Object} [options.requestOpts] - default request options of [urllib](https://www.npmjs.com/package/urllib) * @param {Function} [options.handler] - special how to handler response */by default, will return response.data.data, you can custom it by handler:
newSDK({handler(res){// should handler error yourselfif(res.status!==200){consterr=newError(res.data.message);/* istanbul ignore next */err.status=res.data.status||res.status;err.code=res.data.code;err.data=res;throwerr;}// return whatever you wantconst{ data, abilities }=res.data;returndata;},});$http_proxy=http://127.0.0.1:8888 TOKEN=<YOUR_TOKEN> npm testsee Yuque API Docs for more details.
see the source.
see the source.
see the source.
see the source.
- API docs
- JSDocs definition for result info
- add
d.tsor refactor to TypeScript
