When WeChat Mini Programs shares, you need to call an ajax (Promise) request, and then return an object, how to achieve Synchronize?

WeChat Mini Programs will call the onShareAppMessage method when sharing, and he will return an object as a parameter when sharing. But I need to call an ajax method before he return. How about Synchronize?

  • there is a problem with async await implementation. The code and error conclusions are as follows
onShareAppMessage: async function(res) {
    let url = await getCache({key:"WebViewUrl",trafficId:wx.getStorageSync("miniId")})
    ...
    return {
      title: title,
      path: url
    }
}
conclusion: async await can not be used. If onShareAppMessage is an async function, this method is called when sharing, but the shared event is shared by default, instead of using the parameter object of my return
  • the question now is how to get the off-duty code Synchronize to implement. The object of return cannot be written into the .then method of the request method, otherwise there will be the above problem: the method will be called, but the sharing event does not take the parameters of return.
onShareAppMessage:function(res) {
    let url;
    getCache({key:"WebViewUrl",trafficId:wx.getStorageSync("miniId")}).then(cache =>{
        url = cache
    })
    return {
      title: title,
      path: url
    }
}

try replacing the ajax request with Synchronize? Jquery can be set as follows:

  

did the landlord solve the problem? I have the same problem

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ec07c1-2ad7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ec07c1-2ad7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?