This is my first time using Angular, Edge.js or calling an API. I'm not sure if I'm doing things right, but I'm surely doing something wrong because it's not working.
To get the data from the API written in C# I'm using Edge.js in a service in my Angular project.
data.service.ts:
import { Injectable, ValueProvider } from '@angular/core';
import * as edge from "edge";
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor() { }
getData(type: string, method: string) {
let data = edge.func({
assemblyFile: 'C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin\CC.CommonInterfaces.dll',
typeName: `CC.CommonInterfaces.${type}`,
methodName: `${method}`
});
return data(null, function(error, result) {
if (error) throw error;
console.log(result);
return result;
});
}
}
Then I'm simply calling the getData method with the right parameters in a component like this:
onClickTestAPI() {
this.dataSrv.getData("IState", "IsTunnelActive");
}
But when running the web server, the console output shows this:
core.js:4002 ERROR Error: Uncaught (in promise): Error: Unexpected token '<'
Evaluating https://localhost:8888/edge
Loading ccui/ccui.umd.js
SyntaxError: Unexpected token '<'
at eval (<anonymous>)
at Qe (system.js:4)
at system.js:4
at T (system.js:4)
at T.h (system.js:4)
at T (system.js:4)
at system.js:4
at system.js:4
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.js:26255)
at resolvePromise (zone.js:852)
at zone.js:762
at rejected (tslib.es6.js:69)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.js:26255)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
at zone.js:910
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:26246)
There isn't even an API response (or at least I can't find it).
Any idea where I went wrong?