Loading…

How to automatically read the appid of the mini program and obtain the exclusive domain name

First, please understand what a dedicated domain name is: ["**What is an exclusive domain name? **》](https://www.yuque.com/apifm/doc/qr6l4m) "apifm" supports checking your exclusive domain name through appid, and then automatically connects to your backend. The specific operation steps are as follows: # Read the current applet appid ```javascript const accountInfo = wx.getAccountInfoSync() const appid = accountInfo.miniProgram.appId ``` Through the above code, you can obtain the appid information of the currently running applet. # Get exclusive domain name You can quickly obtain your exclusive domain name through any of the following methods ## Obtained through apifm-wxapi SDK ```javascript const res = await WXAPI.fetchSubDomainByWxappAppid(appid) if (res.code == 700) { // You have not configured the appid in the background, so you cannot obtain the exclusive domain name. } else if (res.code != 0) { // Failed to obtain } else { const subDomain = res.data } ``` ## Call the api interface to obtain ![](https://dcdn.it120.cc/yuque/0/2020/png/572726/1587818924232-b5976c2d-93bc-45e8-b609-ee5f8305799c.png)