-1

this is my fetch function, it is working but i didn't get result return the function.


        protected CallFunction(vadetarihi) {
            

            var xfrs = this.getCookie('CSRF-TOKEN');

            if (xfrs) {
              fetch('/Hasfin/PaymentList/GetDateRestriction', {
                    method: 'POST',
                    headers: {
                        'Accept': 'application/json, text/javascript, */*; q=0.01',
                        'Content-Type': 'application/json',
                        'X-CSRF-TOKEN': xfrs
                    },
                    body: JSON.stringify({ "VadeTarihi": vadetarihi.substring(0, 10), "VadeIstenenTarih": new Date().toJSON().slice(0, 10) })

                }).then((dt) => {

                    return dt.json() as Promise<{ data }>

                   /* dt.json().then(post => {
                        console.log(post);
                        return post;
                    })*/
                }).then(data => {
                
                    return data.data

                }).catch((ex) => {
                    console.log(ex)
                });
            }
       
        }

I am calling here ;

   let _row = (ctx.item as PaymentListRow);
                    if (_row.VADE != null) {
                     
                        var xx = this.CallFunction(_row.VADE)
                        console.log(xx);
                        return "" + xx;
                    }

xx coming undefined. It should be return a number.

Please help me, what is wrong my function?

0 Answers0