angular - NativeScript 没有得到 Set-Cookie
问题描述
我正在用 Nativescript 构建一个应用程序,但是在执行登录功能时我有一些奇怪的行为,就像在我所做的第一次登录调用中,我得到了“Set-Cookie”标头,但随后我注销,然后当我这样做时再次登录我不再得到那个标题了。
下面你有登录服务:
_loginPost(url: string, params: any): Promise<any> {
return new Promise<Response>((resolve, reject) => {
const res = new Response();
if (this.checkConnection()) {
this.http.post(this.endpoint + url, params, {
observe: "response",
"Content-Type": "application/json"
}).toPromise().then((response: any) => {
try {
const cookie = response.headers.get("Set-Cookie");
res.wasSuccess(cookie.slice(0, cookie.indexOf(";")).toString());
} catch (error) {
res.failed("ERROR");
}
resolve(res);
}, (e) => {
if (e && e.error) {
if (e.status === 403) {
res.failed("MUST_LOGOUT");
} else {
res.failed(e.error.cause);
}
} else {
res.failed("ERROR");
}
resolve(res);
});
} else {
res.failed("No Internet Conection");
resolve(res);
}
});
}
下面你有两个请求的图像
解决方案
推荐阅读
- python-3.x - numpy 和 pandas 中的嵌套条件不起作用
- php - 为什么 PHP 内置的 web 服务器不应该在公共网络上使用?
- swift - 2020年,有没有办法使用Swift分别处理菜单栏的左右点击?
- amazon-web-services - AWS:两个 AZ 中的两个私有子网可以共享同一个 NAT 网关吗?
- javascript - 使用 jquery append 添加 svg 元素
- python - np.multiply() 的源代码位置在哪里
- regex - Perl 多行正则表达式匹配和删除
- .net-core - 将 .NET Core 对象作为每个类型的单例实例注入?
- build - 添加自定义源文件后,在 Segger Embedded Studio 上构建失败,没有说明原因
- vba - VBA Selenium - 等待 iframe 加载