当部署到heroku时,我的PC正确传递了localstorageID,我可以将其用于ajax调用,但是在我的手机上却不能。
$('#save_entry').on('click', function (e) {
e.preventDefault();
var elements = $('#newEntryForm')[0].elements
var title = elements[0].value
var content = elements[1].value
// localStorage.getItem('userID')
// localStorage.setItem('userId', author)
var author = localStorage.userID
$.ajax({
url: '/api/entries',
method: 'POST',
data: {
title,
content,
author
},
success: function (res) {
window.location.href = "./history";
},
error: function (err) {
console.log(err);
alert(`Sorry, your post didn't go through`);
}
});
在PC上作者获得通过,但在移动设备上未获得通过。谢谢您的帮助。