Hello i am trying to make a background “Silent” call to webservice in order to get a token
i am struggling with ajax.
I studied an example that i found in Angular 1 which uses Ajax for some reason
and because i am newbie i decided to immitate the same code in angular 5 but i getting issues.
here is my code @ serviceprovider.ts
import { HttpClient } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import ‘rxjs/add/operator/map’;
import {Observable} from “rxjs/Observable”;
import ajax // ERROR here
var token ="";
@Injectable()
export class LoginserviceProvider {
url=‘http://192.168.0.6:81/EBSWebApi’;
token="";
constructor(public http: HttpClient) {
console.log(‘Hello LoginserviceProvider Provider’);
this.url=‘http://192.168.0.6:81/EBSWebApi’;
}
ready(){
ajax({
url:this.url+ “api/login”,
type:“POST”,
data:JSON.stringify({
SubscriptionPassword: “passx”,
model: {
UserID: “khcadmin”,
UserPassword: “00100100957”,
BranchID: “01”,
AllowHttp: true
}
}),
contentType:“application/json; charset=utf-8”,
success:function (result) {
token = result.Model.WebApiToken;
document.getElementById(“token”).innerText=token;
}
})
}