I am newbie in Angular 6 and TypeScript. Can someone show me the right way to use node.js third-party module in Angular 6?
For example i want to create component with ability to consume and make requests to SOAP wsdl methods.
Did installed it by adding to package.json with npm install
.
Trying to use node-soap npm module like this:
import { Injectable } from '@angular/core';
import * as soap from 'node-soap';
@Injectable({
providedIn: 'root'
})
export class MySoapService {
constructor() { }
getOrderInfo() {
const url = 'http://my-example-api.com/WCF/ClientService.svc?singleWsdl';
let args = {
login: 'login',
password: 'password',
orderNumber: 'F976638'
};
soap.createClient(url, function(err, client) {
client.GetOrderInfo(args, function(err, result) {
console.log(result);
});
});
};
}
Then inject this service into component and render it, just to test the service...
But got some error during ng serve
:
ERROR in ./node_modules/node-soap/client.js
Module not found: Error: Can't resolve 'http' in '/home/cadistortion/WebstormProjects/my-ng-app/node_modules/node-soap'
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…