I’m trying to set up a microservice using DDP-connection in my meteor application. But the code gives me an invoking Method
error, which I do not understand.
So what is wrong with my code?
This is my example microservice, which is running on port 3100:
Example microservice
/server/methods.js
import { Meteor } from 'meteor/meteor';
Meteor.methods({
"exampleMethod": function(param) {
console.log(param);
return [ 'result' ];
}
});
Main application
/server/main.js
import { Meteor } from 'meteor/meteor'
var exampleConnection = DDP.connect("http://localhost:3100");
Meteor.defer(function() {
exampleConnection.call('exampleMethod', 'param');
});
How do I call the method in my main application?
Main application
/imports/ui/example.jsx
import React, { Component } from 'react'
export default class Example extends Component {
handleChange(event) {
Meteor.call('exampleMethod', 'param', function(error, result) {
console.log(result);
});
}
render { return (<Anything />); }
}
So with this I would expect the console output of parameter and the result. But this concept doesn’t work. I’m getting an Error invoking Method 'exampleMethod': Method 'exampleMethod' not found [404]
error.