Javascript animate json data on loop

Hi

I’m testing out a Realm app with a database from Atlas.

I have a GET webhook exposing the entire database as an array, but need the database to be output in a single field as an animation loop sequence (like a stop watch counter.)

Here is the function I’m working on:

exports = function(payload) {

 const mongodb = context.services.get("mongodb-atlas");

 const mycollection = mongodb.db("mydatabase2").collection("mycollection2");

 return mycollection.find({}, {_id:0}).toArray();

};

and the webhook database output as static array, instead of animation loop.

Please help, I am still learning) and would love to make use of MongoDBxRealm apps properly!

Many thanks, Andi

PS

So instead of exposing the entire database as a static array:

[{"id":"214"},{"id":"301"},{"id":"2110"},{"id":"152"}]

The webhook will loop through the database infinitely as an animated sequence shown as a single field:

[{"id":"214"}]

Thank you!

Hi @a_Jn,

The webhook is designed to output a static value and it cannot animate your front end result.

What you need is to write a front end code that with a setTimeout will get the next value and update the screen output and as a result does this animation.

Thanks
Pavel

1 Like

Thank you Pavel, this sounds like a good solution!

1 Like