Moleculer: How to get FormData object in request body?

Created on 12 Aug 2018  路  3Comments  路  Source: moleculerjs/moleculer

i have a FormData object in front-end (ReactJs) and i add it to body of request
how i can get this object in moleculer back-end.
i try this.ctx.params but it is not work

Most helpful comment

Moleculer service hasn't http server by default. If you want accept http requests, you should mixin your service with http server (create http server in created hook, start listen on started hook, then handle requests and call appropriate methods of your service).

All 3 comments

Moleculer service hasn't http server by default. If you want accept http requests, you should mixin your service with http server (create http server in created hook, start listen on started hook, then handle requests and call appropriate methods of your service).

@quex46 hi, I am newbie in nodejs and i still confusing what the should I do to "create http server in created hook start listen on started hook, then handle requests and call appropriate methods of your service" may I see the example code for the created and started function, thanks for the help

@siridho The base moleculer framework provides the components to build brokered microservices which can communicate with each other using the broker over a multitude of transports. It's as simple as that. If you want/need to create a service which handles HTTP requests itself (essentially either acting as an API gateway routing requests to the service itself or other services registered on the bus) you may want to look at the Moleculer-Web project. It's a service mixin which will provide the HTTP server setup for you, you simple need to configure it.

You can of course set this up yourself but I personally think that this mixin works great and is highly configurable so you will probably find that it will do exactly what you need.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dylanwulf picture dylanwulf  路  4Comments

SushKenyNeosoft picture SushKenyNeosoft  路  3Comments

rozhddmi picture rozhddmi  路  4Comments

molobala picture molobala  路  3Comments

Kamil93 picture Kamil93  路  3Comments