Open
Description
Hi, I'm using a firebase callable function and would like to send the repsponse back to the client once the transaction is completed - instead of sending another post to a different URL. The only problem is that the APIOperationBase.execute does not return the response.
Is there a reason for this?
It would be much more efficient if I could do this...
` try {
const THE_RESPONSE_FOR_CLIENT = ctrl.execute(function(){
var apiResponse = ctrl.getResponse();
var response = new ApiContracts.CreateTransactionResponse(apiResponse);
//pretty print response
console.log(JSON.stringify(response, null, 2));
if(response != null){
if(response.getMessages().getResultCode() == ApiContracts.MessageTypeEnum.OK){
if(response.getTransactionResponse().getMessages() != null){
console.log('Successfully created transaction with Transaction ID: ' + response.getTransactionResponse().getTransId());
console.log('Response Code: ' + response.getTransactionResponse().getResponseCode());
console.log('Message Code: ' + response.getTransactionResponse().getMessages().getMessage()[0].getCode());
console.log('Description: ' + response.getTransactionResponse().getMessages().getMessage()[0].getDescription());
}
else {
console.log('Failed Transaction.');
if(response.getTransactionResponse().getErrors() != null){
console.log('Error Code: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorCode());
console.log('Error message: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorText());
}
}
}
else {
console.log('Failed Transaction. ');
if(response.getTransactionResponse() != null && response.getTransactionResponse().getErrors() != null){
console.log('Error Code: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorCode());
console.log('Error message: ' + response.getTransactionResponse().getErrors().getError()[0].getErrorText());
}
else {
console.log('Error Code: ' + response.getMessages().getMessage()[0].getCode());
console.log('Error message: ' + response.getMessages().getMessage()[0].getText());
}
}
}
else {
console.log('Null Response.');
}
callback(response,finalMessage);
console.log('response,finalMessage');
console.log(ctrl._response );
});
return THE_RESPONSE_FOR_CLIENT;
} catch (error) {
throw new functions.https.HttpsError('unknown', error);
}`