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
js/electron.jsfile. 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?
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.jsand send data to
sendSocketNotification(). Your module can get the data with
socketNotificationReceived(). It is a more kindly way to other people.
@Sean Nice! Can you show example project where you have done it like this?
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