AppB subscribe to AppA result data empty
// ------ App A -------
// run http://localhost:3000
//bookCollection.js
import { Mongo } from "meteor/mongo";
const BookCollection = new Mongo.Collection("bookCollection");
export default BookCollection;
//publish.js
import { Meteor } from "meteor/meteor";
import BookCollection from './bookCollection';
Meteor.publish('books', function () {
return BookCollection.find({});
}
// --------- App B ---------
// run http://localhost:5000
//index.js client
import { Meteor } from "meteor/meteor";
Meteor.connection = DDP.connect('http://127.0.0.1:3000');
//colletions.js
import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import { DDP } from "meteor/ddp-client";
export const BookCollection = new Mongo.Collection("bookCollection",{connection:Meteor.connection});
export const CategoryCollection = new Mongo.Collection("categoryCollection",{connection:Meteor.connection});
//main.vue
import { BookCollection } from './colletions'
mounted(){
let handle = Meteor.connection.subscribe('books');
if(handle.ready()){
console.log(BookCollection.find({}).fetch());
// result empty
}
}
BookCollection cannot get data from remote App A
How to config subscribe
Thank you.