Hi!
What should I do to access my ionic cordova angular app to remote Microsoft SQL database?
This will be to read and store data into and from my APP input fields.
Hi!
What should I do to access my ionic cordova angular app to remote Microsoft SQL database?
This will be to read and store data into and from my APP input fields.
Write a REST middleware application server to respond to GET/POST/PUT/DELETE requests and interact appropriately with the database.
Do you have a guideline, direct and clear?
@yamurkahtan Did you ever find a solution to this, found this plugin https://www.npmjs.com/package/cordova-plugin-sqlserver but still can’t find enough examples on how to directly connect to your sql server
even if its too late, like precedent answer, you have to deal with REST middleware
i have a laravel backend api i use for authentication and CRUD operation
write a service and inject it for use. Here how my auth service looks like :
export class AuthService {
public token: any;
constructor(public http: Http, public storage: Storage) { }
checkAuthentication(){
return new Promise((resolve, reject) => {
//Load token if exists
this.storage.get('token').then((value) => {
this.token = value;
let headers = new Headers();
headers.append('Authorization', this.token);
this.http.get('http://localhost:8000/api/products', {headers: headers})
.subscribe(res => {
resolve(res);
}, (err) => {
reject(err);
});
});
});
}
login(credentials){
return new Promise((resolve, reject) => {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
this.http.post('http://localhost:8000/api/login', JSON.stringify(credentials), {headers: headers})
.subscribe(res => {
let data = res.json();
this.token = data.token;
this.storage.set('token', data.token);
resolve(data);
resolve(res.json());
}, (err) => {
reject(err);
});
});
}
logout(){
this.storage.set('token', '');
}