Cybersource return instance response on nuxt $fetch call

I’ve created the below code in nuxt3 as a serverside api ‘server/api’ and I am calling this using: const { payresponse } = await $fetch( '/api/cybersource/', {}

However I cannot get the return value from const response = await instance.createPayment

When I’ve tried console.log. this is alway fired before the console.log within the instance even though I’ve used await

    'use strict';

import cybersourceRestApi from 'cybersource-rest-client';

export default defineEventHandler( async (event) => {
        
        
        const AuthenticationType = 'http_signature';
        const RunEnvironment = 'apitest.cybersource.com';
        const MerchantId = 'testrest';

        // http_signature parameters
        const MerchantKeyId = '08c94330-f618-42a3-b09d-e1e43be5efda';
        const MerchantSecretKey = 'yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=';

        // jwt parameters
        const KeysDirectory = 'Resource';
        const KeyFileName = 'testrest';
        const KeyAlias = 'testrest';
        const KeyPass = 'testrest';

        //meta key parameters
        const UseMetaKey = false;
        const PortfolioID = '';

        // logging parameters
        const EnableLog = true;
        const LogFileName = 'cybs';
        const LogDirectory = 'log';
        const LogfileMaxSize = '5242880'; //10 MB In Bytes
        const EnableMasking = true;

        var merchantDetails = {

                'authenticationType': AuthenticationType,
                'runEnvironment': RunEnvironment,

                'merchantID': MerchantId,
                'merchantKeyId': MerchantKeyId,
                'merchantsecretKey': MerchantSecretKey,

                'keyAlias': KeyAlias,
                'keyPass': KeyPass,
                'keyFileName': KeyFileName,
                'keysDirectory': KeysDirectory,

                'useMetaKey': UseMetaKey,
                'portfolioID': PortfolioID,
                //'pemFileDirectory': PemFileDirectory,

                'logConfiguration': {
                    'enableLog': EnableLog,
                    'logFileName': LogFileName,
                    'logDirectory': LogDirectory,
                    'logFileMaxSize': LogfileMaxSize,
                    'loggingLevel': 'debug',
                    'enableMasking': EnableMasking
                }
        }
        try {

          var configObject = merchantDetails;
          var apiClient = new cybersourceRestApi.ApiClient();
          var requestObj = new cybersourceRestApi.CreatePaymentRequest();
      
          var clientReferenceInformation = new cybersourceRestApi.Ptsv2paymentsClientReferenceInformation();
          clientReferenceInformation.code = 'TC50171_3';
          requestObj.clientReferenceInformation = clientReferenceInformation;
      
          var processingInformation = new cybersourceRestApi.Ptsv2paymentsProcessingInformation();
          processingInformation.capture = true;
          requestObj.processingInformation = processingInformation;
      
          var paymentInformation = new cybersourceRestApi.Ptsv2paymentsPaymentInformation();
          var paymentInformationCard = new cybersourceRestApi.Ptsv2paymentsPaymentInformationCard();
          paymentInformationCard.number = req.cardnumber;
          paymentInformationCard.expirationMonth = req.expirymonth;
          paymentInformationCard.expirationYear = req.expiryyear;
          paymentInformation.card = paymentInformationCard;
      
          requestObj.paymentInformation = paymentInformation;
      
          var orderInformation = new cybersourceRestApi.Ptsv2paymentsOrderInformation();
          var orderInformationAmountDetails = new cybersourceRestApi.Ptsv2paymentsOrderInformationAmountDetails();
          orderInformationAmountDetails.totalAmount = req.amount;//'122.00';
          orderInformationAmountDetails.currency = req.currency;//'GBP';
          orderInformation.amountDetails = orderInformationAmountDetails;
      
          var orderInformationBillTo = new cybersourceRestApi.Ptsv2paymentsOrderInformationBillTo();
          orderInformationBillTo.firstName = req.cardholderf;
          orderInformationBillTo.lastName = req.cardholderl;//'Doe';
          orderInformationBillTo.address1 = req.address1;//'1 Market St';
          orderInformationBillTo.locality = req.address2;//'san francisco';
          orderInformationBillTo.administrativeArea = req.state;//'CA';
          orderInformationBillTo.postalCode = req.postcodde;//'94105';
          orderInformationBillTo.country = req.country;//'GB';
          orderInformationBillTo.email = req.email;//'[email protected]';
          orderInformationBillTo.phoneNumber = req.phone;//'4158880000';
          orderInformation.billTo = orderInformationBillTo;
      
          requestObj.orderInformation = orderInformation;
      
      
          var instance = await new cybersourceRestApi.PaymentsApi(configObject, apiClient);

          const response = await instance.createPayment(requestObj, function (error, data, response) {
            if (error) {
              console.log('nError : ' + JSON.stringify(error));
            }
            else if (data) {
              console.log('nData : ' + JSON.stringify(data));
            }

            console.log('nResponse : ' + JSON.stringify(response));
            console.log('nResponse Code of Process a Payment : ' + JSON.stringify(response['status']));
            
            return {
              error: error,
              data: data,
              response: response
            };
            
          });

          return response;
        }
        catch (error) {
          console.log('nException on calling the API : ' + error);
          return { error };
        }
  }
  else
  {
    return false;
  }

}
);

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật