我收到了我的this.http.post
的回复。下面是我的代码需要在本地存储中保存和检索Http post response
this.http.post('http://funiks.com/adminv7/offline-api/login.php', {username: user_form_value,password: password_form_value})
.subscribe(
(response)=> console.log(response)
);
,我想通过这样的在本地存储保存响应,这是我做的JS,但请指导我如何能节省的角度和确切位置我需要把代码 -
localStorage.setItem("getLoggedInUserANG",JSON.stringify(response));
请指导,同样我如何得到结果回来变量? 在JS我喜欢这一点,并从数据::
loggeduser_array = JSON.parse(localStorage.getItem("getLoggedInUser"));
console.log(loggeduser_array.username);
这是我得到我的js代码的结果 - https://pastebin.com/tb1dGA1f,如何成功和获取data.user使用,如在这样的js中 - “$ .ajax({0} 0%{url = 'http://funiks.com/adminv7/offline-api/login.php', type:'POST', contentType:'application/json;字符集= UTF-8' , 数据类型: 'JSON', 数据:JSON.stringify(字典), }) .done(功能(数据,textStatus,jqXHR){ \t如果(data.status ==” SUCCESS“)localStorage.setItem(”getLoggedInUser“,JSON.stringify(data.user));'但在角度我得到这个 - https://pastebin.com/W49NAQvz,如何获得相似的结果?? – user2828442
使用'JSON.parse(response._body).user',因为响应正文是一个字符串,而不是一个对象 – HARI
但我不能保存我使用html5或js保存的东西,角度我在本地节省了太多不需要的东西存储,我只想保存与使用我的html5方法保存类似的东西,请指导我如何做到这一点 – user2828442