question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling "no data" scenario

See original GitHub issue

Hello,

I’m wondering how to handle the “no data” scenario with the FlowRouter. Let’s say I want to have a route /article/:slug on which I want to render an Article (fetched by the slug field) along with related comments (separate collection). So I’ll define a route like this:

FlowRouter.route('/article/:slug', {
  subscriptions: function(params) {
    this.register('article', Meteor.subscribe('articleSlug', params.slug));
    this.register('comments', Meteor.subscribe('commentsByArticleSlug', params.slug));
  },
  action: function() {
    FlowLayout.render('appLayout', { main: "articleDetail" });
  }
});

In the template I’ll display the article details & comments when when subs are ready, until then just “loading…” text.

But what if the :slug param in the URL doesn’t match any article in the DB? I don’t want to keep displaying the “loading…” text, I want to display some sort of “Article not found” message. How to do this?

Thanks for any advice.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
delgermuruncommented, Apr 7, 2015

Hello @michalvalasek,

It’s not really router’s issue. You can check subsReady() on your template helper. If it’s ready server sent data.

So you can check whether article exist or not on client. a = Articles.findOne({slug: slug}) if (a) ... smth like than. if a is undefined, you can show another template or redirect to not-found page.

PS: I hope you understand me. But if you don’t feel free to ask further. I can show you code example. I can’t explain well, cause my English isn’t good enough 😃.

0reactions
arunodacommented, May 18, 2015

This is a middleware and data handling related issue and related with #80. So, I’m closing this and let’s discuss at #80

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Handling Scenarios: Part #1 - Heartbeat
Learn techniques for handling common dataset challenges: Read CSV, converting categories, and finding empty strings in a dataframe.
Read more >
NO_DATA_FOUND in Functions - Ask TOM
no_data_found is not an error - it is an "exceptional condition". You, the programmer, decide if something is an error by catching the...
Read more >
Tackling Missing Value in Dataset - Analytics Vidhya
The first step in handling missing values is to look at the data carefully and find out all the missing values. The following...
Read more >
increase should handle no data to has data scenario #7270
I tried to work it around by adding vector(0) to fill the no data period, but it doesn't have the same label 'pod'...
Read more >
PL/SQL block problem: No data found error - Stack Overflow
When you are selecting INTO a variable and there are no records returned you should get a NO DATA FOUND error. I believe...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found