Reputation: 123
I am checking my angular project with tslint, and I am getting this error from which I don't understand the reason. The error is: expected an assignment or function call
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
this.loading = false;
this.printingOrders = response.data;
this.totalNumberOfCharacters = 0;
this.totalNumberOfCharactersNext = 0;
if (this.printingOrders.labelPresentOrder && this.printingOrders.labelPresentOrder.lines) {
this.printingOrders.labelPresentOrder.lines.forEach(
line => {
this.totalNumberOfCharacters += line.length;
}
);
}
if (this.printingOrders.labelNextOrder && this.printingOrders.labelNextOrder.lines) {
this.printingOrders.labelNextOrder.lines.forEach(
line => {
this.totalNumberOfCharactersNext += line.length;
}
);
}
if (this.printingOrders.printing) {
this.suscribeNotifications();
}
}
), err => {
this.loading = false;
this.alertService.error(INFO_NO_EXISTEN_ORDEN_PREPARADA);
this.hasAlert = true;
};
}
The error is in this line:
this.imprimirService.getInfoPrinting().subscribe(
What am I doing wrong?
Thanks.
Upvotes: 3
Views: 908
Reputation: 692201
Your code is incorrect. Instead of
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
...
}
), err => {
...
};
}
It should be
getInfoPrinting() {
this.imprimirService.getInfoPrinting().subscribe(
response => {
...
},
err => {
...
});
}
The error would be much easier to spot if the method body was shorter. You should delegate to a separate method inside your callback.
Upvotes: 4