Closed ramukodandapuram closed 7 years ago
getting error like this:
https://www.00.000.00.00:8080/api/WebApi/Login net::ERR_NAME_NOT_RESOLVED
I don't where I did mistake. Please help me!!
here is my code:
HomePage: home.html
home.ts import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { AuthServiceProvider } from '../../providers/auth-service/auth-service'; import { ListPage } from '../../pages/list/list'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage {
username: String; password: String; data: any; //loading: any; constructor(public navCtrl: NavController, private authService: AuthServiceProvider ) {
} ngOnInit() {
} login(username,password) { this.authService.login(this.username, this.password).then(result => { this.data = result; localStorage.setItem('token', this.data.access_token); this.navCtrl.setRoot(ListPage); }, (err) => { alert(error); }); }
}
auth-service.ts
import { Injectable } from '@angular/core'; import { Http, Headers } from '@angular/http'; import 'rxjs/add/operator/map';
@Injectable() export class AuthServiceProvider {
http: any; baseUrl: String;
constructor(http: Http) { //console.log('Hello AuthServiceProvider Provider'); this.http = http; this.baseUrl = 'https://www.00.00.000.00:8080/api';
} login(username, password) {
return new Promise((resolve,reject) =>{ let headers = new Headers(); headers.append('Content-Type', 'application/json'); return this.http.post(this.baseUrl + '/'+'WebApi/Login', JSON.stringify(username, password), { headers: headers }) .subscribe(res => { resolve(res.json()); }, (err) => { reject(err); }); });
your base URL is the problem.
thank you. I changed url its working fine now.
getting error like this:
https://www.00.000.00.00:8080/api/WebApi/Login net::ERR_NAME_NOT_RESOLVED
I don't where I did mistake. Please help me!!
here is my code:
HomePage: home.html
home.ts import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { AuthServiceProvider } from '../../providers/auth-service/auth-service'; import { ListPage } from '../../pages/list/list'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage {
} ngOnInit() {
}
auth-service.ts
import { Injectable } from '@angular/core'; import { Http, Headers } from '@angular/http'; import 'rxjs/add/operator/map';
@Injectable() export class AuthServiceProvider {
constructor(http: Http) { //console.log('Hello AuthServiceProvider Provider'); this.http = http; this.baseUrl = 'https://www.00.00.000.00:8080/api';
} login(username, password) {
}
}