Read the statement by Michael Teeuw here.
What is right way to do http request on my custom module?
-
At the moment I am calling my external endpoint with XMLHttpRequest in my custom module. But the server has CORS setting on. My current workaround for that is that I am adding
webSecurity: false
insideelectronOptionsDefaults
injs/electron.js
file. This allows me to do requests to the server without CORS problem.My question is there a correct way to do http requests in custom modules? Are there any disadvantages in my current solution?
-
@henrikra
If you have a plan to release that module publicly, you should provide instruction how people to do that solution.Usually, do your job in
node_helper.js
and send data tomodule
withsendSocketNotification()
. Your module can get the data withsocketNotificationReceived()
. It is a more kindly way to other people. -
@Sean Nice! Can you show example project where you have done it like this?
-
@henrikra
Default news feed module doesn’t use xmlHttpRequest, but you can get an idea how to comunicate between module and node_helper. -
Thank you so much! You have guided me to right direction and now I am doing requests the right way in node_helper :)