Trying to access just the value or key of the JSON object but it displays as undefined.
Tried to json.parse but same results.
now = datetime.now()
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
print(date_time)
chatrooms[chatroom][username][date_time] = message
message = json.dumps(chatrooms[chatroom][username])
emit("append messages", message, broadcast=True)
socket.on('append messages', data => {
const li = document.createElement('li');
// parse the messages;
var response = jQuery.parseJSON(data)
message = `${response.date_time}`;
The message that was sent in, but I am getting undefined. I tried ridding of the jQuery Parse, but it is not working.
data, it's an object already 3.message = response.date_time;data? does it contain valid json, the entire json and nothing but the json?emit()already encodes the passed payload? what happens if you tryemit("append messages", chatrooms[chatroom][username], broadcast=True)? Sidenote: JSON is always a string; it's a serialization format. What you probably have in mind are Object literals.