1

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
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
user1119383
  • 41
  • 2
  • 5

2 Answers2

0

Use AMF.js, which is the subject of a related question which discusses the syntax and debugging process.

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
0

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>
<% } %>