Handling "no data" scenario
See original GitHub issueHello,
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:
- Created 8 years ago
- Comments:13 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 isundefined
, 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 😃.
This is a middleware and data handling related issue and related with #80. So, I’m closing this and let’s discuss at #80