【发布时间】:2023-02-01 17:28:11
【问题描述】:
在我的 React Native Expo 项目中,我遇到了一个错误,上面写着“TypeError: JSON.stringify cannot serialize cyclic structures.stringify@[native code]” 谁能帮我解决这个问题?我尝试使用一个名为“json-stringify-safe”的库,但在像“body: jsonStringifySafe(MessageData)”这样使用它之后,它给我 react-navigation error 谁能帮我解决这个错误?
const SendMessage = async () => {
const MessageData = {
message: currentmessage,
RoomId: roomid,
SenderId: mydata._id,
RecieverId: otheruser[0]._id
};
fetch('http://10.0.2.2:3000/saveMessage', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(MessageData),
})
.then(res => res.json())
.then(data => {
if (data.message === "Message Saved!") {
console.log("Message Saved!");
setCurrentMessage('');
} else {
alert("Please, Try Again");
}
});
};
【问题讨论】:
标签: javascript reactjs react-native