What is returned now is that what GX, wants to return is the request result, but the result is in the callback?

Template.measurementTable.onCreated(() => {
    const instance = Template.instance();
    const patientName=instance.data.studies[0].patientName;
    xnatInstance.get(`http://10.2.10.106:5199/mri/predict?pid=${patientName}`).then((respose)=> {
        console.log(respose.data.msg);
         instance.datas=respose.data.msg;
    });
    instance.datas="GX";
});
Template.measurementTable.helpers({
    datas() {
        const instance = Template.instance();
        if (instance.datas!=="GX") {
            return instance.datas;
        }
        return instance.datas;
    }
});

what is returned now is that the content that GX, wants to return is the request result, but in the callback of the result, what should be done if the GX, is returned in the order of execution? How should I write it in async and await?

Mar.14,2022

if you use the callback writing method, to process the request result, you need to process the data in the callback function, and to ensure the order, you need to nest the callback function.

const dataA = await post({url="https://domain.com/api/a"})
const dataB = await post({url="https://domain.com/api/b"})
console.log(dataA)
console.log(dataB)

then you need to use async/await

Menu