javascript - 使用包含已验证电话号码值的 cookie 标记 Google 地图标记
问题描述
这是我创建 cookie 以保存已验证电话号码的地方
'signInSuccess': function(user, credential, redirectUrl) {
// You can also access this via firebase.auth().currentUser.phoneNumber
document.cookie = (firebase.auth().currentUser.phoneNumber);
handleSignedInUser(user);
// Do not redirect.
//'signInSuccessUrl': "http://localhost:8080/CurrentLocation.html",
return true;
}
这是我使用 cookie 值来标记 Google 地图标记的地方
var markerLabel = document.cookie;
var marker = new google.maps.Marker({
position: {
lat: data.User.l[0],
lng: data.User.l[1]
},
map: map,
label: markerLabel
});
标记标签说
电话号码=未定义;+1##########
它显示用户的验证号码,但也显示未定义。我只想显示电话号码。
解决方案
您没有正确设置 cookie。查找设置/获取 cookie 的正确方法:https ://www.w3schools.com/js/js_cookies.asp
另外,为什么需要使用cookie来保存电话号码?Firebase Auth 已经保留了用户。在监听器触发firebase.auth().currentUser.phoneNumber
后,您可以通过调用获取电话号码。onAuthStateChanged
推荐阅读
- javascript - 尝试使用 axios 进行 VueJS API 调用以在名为 prijzen 的组件中获取 json
- html - 函数值如何显示在 HTML 标记中,并带有 addEventListerner click 的返回值?
- ssl - 使用 pip 安装证书验证失败,主要问题,(_ssl.c:1108)
- javascript - useMemo on .map 语句中使用的函数
- python - 对 DASK 中的列中的每个值运行 mysql 查询
- python - 我希望我的角色只要按住按钮就可以做某事,然后在松开按钮后恢复正常
- reactjs - 具有给定令牌的 Axios 拦截器,React
- javascript - vanilla javascript使用链接的点击但不同的命令
- javascript - 触发日期更改时未触发 ng-change 事件
- java - 如何在 Spring Boot 中捕获客户端参数错误的“请求处理失败”?