小编ch *_*ika的帖子

如何用api传递用户名和密码?

我有一个API.如果您打开,则应输入用户名和密码.如何获取该API中的数据?如果我写get("....api-url...."),它显示unauthorized error.如何将用户名和密码传递给该API?

constructor(private _http: Http) {
    this.getMyBlog();
}

private getMyBlog() {
    return this._http.get('http://localhost:8088/.../...')
        .map((res: Response) => res.json())
        .subscribe(data => {
            this.data = data;
            console.log(this.data);
        });
}
Run Code Online (Sandbox Code Playgroud)

angular

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

标签 统计

angular ×1