I am using meteor-react, and I encounter some problems with the external api. In my project, I use pure meteor as server and react as client.
I want to get some data posted using a url's body (sent from external api).
ex: this an example of the url with the body
http:\\api\test
{
name: test
}
I need to get the information in the body.
I really don't know how to implement that in my meteor project, and i don't know from where (whether the server side or client side), I should implement my code.
I have tried these instructions but it is not working:
WebApp.connectHandlers.use('/notif',bodyParser.json());
WebApp.connectHandlers.use('/path', bodyParser.urlencoded());
WebApp.connectHandlers.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
API.handleRequest(res, req);
});
Thanks in advance for your help
What you are looking for is a server-side router. I would recommend https://atmospherejs.com/meteorhacks/picker since it is more light-weight than the default alternative, iron-router.
Add the package to your project:
Add the
body-parsernpm package:In your server code: