I want a simple example of how to send data from a nodeJS server as JSON to Flash, then Flash decodes the JSON. This is part of what I want:
Server
json = {name : "Person", id: "1"}
Flash
myinput.text = json.id + ":" + json.name
I want a simple example of how to send data from a nodeJS server as JSON to Flash, then Flash decodes the JSON. This is part of what I want:
Server
json = {name : "Person", id: "1"}
Flash
myinput.text = json.id + ":" + json.name
Use AMF.js, which is the subject of a related question which discusses the syntax and debugging process.
On server-side:
app.post('/login', (req, res) => {
//Some code with error here...
errorModel = {
code: 400,
message: 'Wrong username or password'
}
req.flash('error', JSON.stringify(errorModel))
res.redirect('/login')
})
On client-side (for example using EJS view):
<% if (messages.error) { %>
<p>
<%= JSON.parse(messages.error).message %>
</p>
<% } %>