@ant-basement/miniprogram-sdk

Ant Basement JavaScript SDK for Alipay MiniProgram

Usage no npm install needed!

<script type="module">
  import antBasementMiniprogramSdk from 'https://cdn.skypack.dev/@ant-basement/miniprogram-sdk';
</script>

README

miniprogram-sdk

NPM

Basement SDK for Alipay Mini Program IDE

Getting Started

npm install --save @ant-basement/miniprogram-sdk

Documentation

API reference please see documentation

Usage

// app.js
App({
  onLaunch(options) {
    basement.user.getInfo().then(res => {
      console.log('user info', res);
    });
    basement.db.collection('task').find().then(res => {
      console.log('task list', res.result);
    });
    basement.function.invoke('sayHello', { name: 'angela' }).then(res => {
      console.log(res.result + ' says angela');
    });

    basement.appService.invoke('myApp', { method: 'GET' }).then(res => {
      console.log(res.result + 'userId say hello to angela');
    });

    my.chooseImage({
      chooseImage: 1,
      success: res => {
        const path = res.apFilePaths[0];
        const options = {
          env: 'public',
          filePath: path,
        };

        basement.file.uploadFile(options).then(res => {
          console.log('file info', res);
        });
      },
    });
  }
});