如果響應成功,我如何在GET後調用http POST服務調用。使用角度2在同一函數中調用GET和POST服務調用
我已經書面按照以下方式get調用,
import {Page, NavController} from 'ionic-angular';
import {Http, Headers} from 'angular2/http';
import 'rxjs/Rx';
@Page({
templateUrl: 'build/pages/login/login.html'
})
export class LoginPage {
constructor(private nav: NavController, public http: Http) {
}
onLogin(value: string): void {
if(this.authForm.valid) {
this.http.get('https://itunes.apple.com/us/rss/topmovies/limit=1/json')
.map(res => res.json())
.subscribe(
data => {console.log(JSON.stringify(data));},
err => this.logError(err),
() => console.log('Random Quote Complete')
);
this.nav.push(AccountViewPage);
}
}
logError(err) {
console.error('There was an error: ' + err);
}
}
爲POST樣品網址:
headers: {"Content-Type": "application/x-www-form-urlencoded" },
ignoreAuthModule: 'ignoreAuthModule'
不能做在用戶中發佈? –