V
V
Vlad Demchuk2021-01-20 12:17:24
JavaScript
Vlad Demchuk, 2021-01-20 12:17:24

How to get JSON data from MongoAtlas as an array to write it to a variable?

I have the following entries in the database:
6007f3a4da424451117363.png

How can I get them into a type variable like this:
6007f3e332cee600286083.png
(This is for an example, in general I want to use this array later with EJS for rendering and displaying on an HTML page, if this can be done in some other way too ideas are welcome)

I just don’t know how to load data from the database into an HTML page, and I still don’t understand anything from the mogoose and MongoDB documentation.
If you know good videos I will be grateful for the link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iredoff, 2021-01-20
@VladDemchuk

The `NeRabotaet` variable returns a Promise. Use

Cars.find({}).then(x => {
    res.send(x)
});

Or you can make it even simpler with await
var NeRabotaet = await Cars.find({});
res.send(NeRabotaet)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question