小编Tod*_*ald的帖子

Ionic2代理不使用离子运行,但使用离子服务?

对于我,ionic.config.json我有:

{
  "name": "TSICMobile",
  "app_id": "6e4680fa",
  "typescript": true,
  "v2": true,
  "proxies": [
    {
      "path": "/api",
      "proxyUrl": "http://192.168.0.105:8081/api"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

在我的提供商(user-data.ts基于Ionic2会议应用程序)中,我有例如:

login(credentials) {
    return new Promise((resolve, reject) => {
        this.http.post(
            '/api/Login',
            JSON.stringify(credentials),
            { headers: this.contentHeader }
        ).subscribe(res => {
            console.log('api/Login return');
            this.data = res.json();
            if (this.data.authenticated === true) {
                this.storage.set('TSIC_USER_PROFILE', JSON.stringify(this.data.tsiC_USER_PROFILE));
                this.storage.set('TSIC_USER_ROLES', JSON.stringify(this.data.listRoles));
                this.storage.set('tsic_id_token', this.data.token);
                this.events.publish('user:login');
                resolve(true);
            } else {
                reject('not authenticated');
            }
        }, error => {
            console.log('api/Login failed');
            reject(error);
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

在跑步时:

ionic serve …
Run Code Online (Sandbox Code Playgroud)

ionic2

7
推荐指数
1
解决办法
3580
查看次数

标签 统计

ionic2 ×1