Basic JDK Demo

Step 1: Application for authorization token

✔️

Warning: ⚠️ For security reasons, the developer token should be always used on the server side. You should never use it in your JS code from the client side.

AuthToken: 👉 {{ authToken }}

Code Example:

const { data: resData } = await axios.post(
  "https://api.lovense.com/api/basicApi/getToken",
  {
    token: “{{token}}”,
    uid: “{{uid}}”,
  }
)
if (resData.code === 0) {
  this.authToken = resData.data && resData.data.authToken
} else {
  throw new Error(resData.message)
}
            
Step 2: Initialize

✔️

Code Example:

const basicJdkInstance = new LovenseBasicJdk({
  platform: "{{ platform }}",
  authToken: "{{ this.authToken }}",
  uid: "{{ this.uid }}",
  debug: true
})
basicJdkInstance.on("ready", (instance) => {
  this.readyStatus = true
})
            
Step 3: Get QR code

✔️

Code Example:

const codeRes = await this.basicJdkInstance.getQrcode()
this.qrcode = codeRes.qrcodeUrl
            
Step 4: Control toys

Connected ✔️ DisConnected

Device 👇

domain: {{ `https://${deviceInfo.domain}:${deviceInfo.httpsPort}` }}

App: {{ `${deviceInfo.appType} - ${deviceInfo.appVersion}` }}

platform: {{ deviceInfo.platform }}

Toys 👇

{{item.name}}