2017-03-08 78 views
0

我使用離子V2,問題是,當我發送HTTP請求它的瀏覽器無法顯示離子http請求沒有被解僱

export class Auth { 

    constructor(public http: Http) { 
    console.log('Hello Auth Provider'); 
    } 

    login(){ 
    console.log('Hello'); 
    this.http.post('localhost:8100/api/User/getAll/' , '' , {}); 

    } 

} 

我火登錄方法,它安慰了「你好」,但不會觸發HTTP

這意味着離子不點火HTTP調用,我已經安裝了白名單的插件,編輯XML文件,並安裝Chrome擴展,但沒有什麼那些解決問題

+0

添加代碼作爲圖像是高度皺眉。請將您的代碼添加爲文本。 –

+0

編輯@Sardar_Usama – wkasem2

回答

0

你必須map()則迴應中使用的subscribe() od,因爲角度Http使用Observables。檢查此

this.http.post('localhost:8100/api/User/getAll/' , '' {}) 
.map(res => res.json()) 
.subscribe(
    response => { 
     console.log(response); 
    }, 
    error => {console.log(error) 
    }); 
+0

工作! , 謝謝 – wkasem2