Я использую эту библиотеку: https://github.com/vpulim/node-soap, чтобы получить данные из API. У меня есть файл apiDecoder.ts со следующим кодом:
class NuSoapClient{
public GetNuSoapInfo():string{
var soap = require('soap')
var url = "https://my.url.com/consultNFSe/server.php?wsdl"
var args = {token. :"mysecrettoken",
doc : "000000000",
number : "000000000"
}
soap.CreateClient(url, function(err, client){
client.MyFunction(args, function(err, result){
console.log(result);
});
});
return
}
}
var nf = new NuSoapClient()
nf.GetNuSoapInfo()
console.log(nf)
Я получаю следующую ошибку при компиляции кода:
" SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:895:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 "
PS: я кодировал ту же функцию в PHP (тоже О.О.) отсутствует аргумент, который я не смог использовать в TypeScript, переменная "consultaNFSe" в переменной $ res. Это определяет, кого я называю в API. Вот рабочий PHP код с Nu soap lib:
$client = new nusoap_client('https://my.url.com/consultNFSe/server.php?wsdl');
$parameters = array('token'=> $results->token,
'cnpj'=> $results->cnpj,
'nrNota'=> $results->nota);
$res = $client->call('consultaNFSe', $parameters);
$contents = file_get_contents("data.php");
$arr = json_decode($res, true);
Есть мысли? Я застрял в этой точке.