0

I have a server with Node.js and I use Express to build a web app. My server is already able to get an array from a database using a function (rss_interrogDB). Now I want to use this array to display a list in the html page. But I must be missing something...

On the server-side my code is:

app.get('/', function(req, res) { 
rss_interrogDB(function() {
// don't konw what to add here
});

On the html page the code is:

$.get('/', {}, function(data){
// not sure it is the right code
console.log(data);
// then the code to create a list from the array (no pb with that)
});

Thank you for your help!

1 Answer 1

1

Assuming your DB gives you an array of data, add something like this to your server code:

app.get('/', function(req, res) { 

    rss_interrogDB(function(serverData) {
        res.send(serverData);             
    });

});

You could manipulate the serverData object and build one that is more suitable for the client before you send it back, but that depends on what you want to do.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. The rss_interrogDB function builds an array. I did what you suggest but then the html page displays directly the array. But I don't want to directly display it, I want it to be use in the html code (to create a beautiful list)...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.