The script error

How can avoid followin error ?
/root/testBitcore/node_modules/bitcore/lib/script/script.js:723
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScri
^
Error: The script type needs to be PayToPublicKeyHash or PayToScriptHash

The error states what the problem is. You’re trying to get an address from a script that is not PayToPublicKeyHash or PayToScriptHash. Only PayToPublicKeyHash or PayToScriptHash scripts can be transformed to addresses

following code is solve that problem ?
txStaticInfo=[];
peer.on(‘tx’, function (tx) {
var transaction = tx.transaction;
transaction.inputs.forEach(function (inputs) {

                   if(inputs.script.isPublicKeyHashIn() || inputs.script.isScriptHashIn()){
                       var address = inputs.script.toString()
                   }

                   intputAddresses.push(address);
               })

               txStaticInfo['inputs'] = intputAddresses;

}