Implement loader with a timeout in Javascript [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm basically calling data from an API and handling the data loading with a loader in my html so when my data array.length is not undefined, the data is shown.
But when there is no data it loads indefinitely...
What I want to do is set a timeout if there is no data, something like 10 seconds in order to display a message like "No data found"
Here is my Vue.js template:

If you search how to print a message after 10 seconds, there is this code:
function stateChange(newState) {
setTimeout('', 10000); //10sec * 1000
if(newState == -1) {
alert('NO DATA');
}
}

Related

How to slow down a node/rabbitmq message/react [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
I have a simulated real time app. I send a csv file to rabbitmq. And rabbitmq sends back the queues. In my client app, ag grid cannot keep with the speed of the received messages. I am using websocket.
I wonder how can I control the speed of those messages, either in rabbitmq, node js, websocket in the server or client? I want to control the speed of each response, e.g. To send/receive every response every second, minute, etc.
Thanks in advance
The solution was to control the flow of the queues. Use prefetch to indicate how many queues you want to consume at each time, and add a set time to indicate how often
channel.prefetch(1);
channel.consume(
queue,
msg => {
if (msg !== null) {
if(msg) {
setTimeout(() => {
console.log(msg.content.toString());
sendQueuesToWebSocket(msg.content.toString());
channel.ack(msg);
}, 50)
}
} else {
console.log('Consumer cancelled by server');
}
},
{
noAck: false,
}
);

Use postMessage to send variable value [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
I got a variable let data = 'testing...123' on a child site, and I embed this page on the parent site by an iframe.
How do I use the API postMessage to send the value of data to the parent site?
Assume I got a paragraph .textHere on the parent site and I want to use the variable from the iframe ( the child site ) on the parent site:
const elm = document.querySelector(.textHere);
function myFunction() {
elm.textContent = data;
}
The explanation from MDN is too deep and I do not understand:
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
on Chile iframe
window.parent.postMessage(
{
val: 'testing...123'
},
"*"
);
on parent
window.addEventListener('message', function(event) {
console.log(event.data.val);
});

How do I fetch user data from firebase without being logged in? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I made a blog which has a database structure as shown below
users:{
$uid:{
Posts:{
$post_id: {...}
}
}
}
I'd like to have a public page where everybody can read the post without being logged in.
How do I fetch the data from firebase as it's clear I need the user id to go deeper
You should change the structure to the following:
users
uid
name : john
age : 100
posts
postId
userId : uid
post: post_content
Then you can do the following:
let ref = firebase.database().ref("posts");
ref.on("value", ((snapshot) => {
snapshot.forEach((childSnapshot) => {
let childData = childSnapshot.val();
console.log(childData.post);
});
});
childData.post will contain all the posts under posts node.

how to post a status in a group using Facebook graph explorer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Https://graph.facebook.com/v2.3/238155829716205
I want to post a status in open group what will be the query using facebook graph api thankyou
Have a look at the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/group/feed#publish
The call is the following
POST /v2.3/{group-id}/feed
with the appropriate fields included.
FB.api(
"/{group-id}/feed",
"POST",
{
"message": "This is a test message"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);

How to convert Markdown to HTML in Node.js / Express / MongoDB app [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have this snippet of code which works just fine; however, is this good design? I'm concerned about the res.send() executing before the for loop has had a chance to finish.
app.get('/api/ideas', function(req, res) {
var query = Idea.find({ status: 'published' }, 'title slug status body pub_date').sort({pub_date: -1});
query.exec(function(err, ideas){
for(i in ideas) {
ideas[i].body = markdown.toHTML(ideas[i].body);
}
res.send(ideas);
});
});
I'm not sure what the toHTML method is but you need to see if it's a synchronous or asynchronous call. If it's synchronous then your design is perfectly fine, and res.send will only execute after the for loop is done. If it's async, then this won't work and send will execute before the for loop is complete.

Categories

Resources