I’ve been trying to figure out why my application is not pulling article data. The site works perfectly on local host with the same records im using in production but for some reason I can’t seem to pull in any data. I tried the galaxy logs and speaking with galaxy support but the logs are showing no errors and support was unhelpful as well. I’ve run the queries my app is running manually in my database and they do return results.
My application has two pages. The homepage which is static content and the news page which is a dynamic route. Pardon the weird route - for seo reasons I need to keep their old news links.
Here is the code snippets to the news page where data is not loading, any help around this would be greatly appreciated!
Container:
import {useDeps, composeWithTracker, composeAll } from 'mantra-core';
import NewsArticle from '../../components/news/NewsArticle';
export const composer = ({context, clearErrors}, onData) => {
const {Meteor, Collections} = context();
if (Meteor.subscribe('articles.viewOne').ready()) {
const options = {};
var urlParam = parseInt(window.location.href.split('=')[1]);
const records = Collections.Articles.findOne({urlpath: urlParam, isOld: true});
onData(null, {records});
} else {
onData();
}
};
export default composeAll(composeWithTracker(composer),useDeps())(NewsArticle);
Component:
import React from 'react';
import DOMPurify from 'dompurify';
import moment from 'moment';
import {DocHead} from 'meteor/kadira:dochead';
class NewsArticle extends React.Component {
constructor(props) {
super(props);
this.state = props.records;
}
render() {
if(this.props.title == undefined) {
DocHead.setTitle('Balkan Business News');
} else {
DocHead.setTitle(this.state.title);
}
var clean = DOMPurify.sanitize(this.state.content);
var desc = clean;
desc = clean.replace(/<\/?[^>]+(>|$)/g, "");
var metaInfo = {name: "description", content: desc.substring(0,250) + '...'};
DocHead.addMeta(metaInfo);
function createMarkup() { return {__html: clean}};
return (
<div className="article">
<h2>{this.state.title}</h2>
<div>{this.state.by} - {moment(this.state.date).format('MMM Do YYYY')}</div>
<div id="textBox" dangerouslySetInnerHTML={createMarkup()}>
</div>
</div>
);
}
}
export default NewsArticle;
and the route around it:
FlowRouter.route('/open-news.php', {
name: 'old.articles',
action() {
mount(MainLayoutCtx, {
content: () => (<NewsArticleContainer />)
});
}
});
My publish code
Meteor.publish('articles.viewOne', function () {
const selector = {};
const options = {};
return Articles.find(selector, options);
});
Articles.deny({
insert() { return true; },
update() { return true; },
remove() { return true; },
});
Kadira pub/sub data
Response Time
7826ms
Sub Rate
1.58/min
Active Subs(Average)
33.16