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: falseinsideelectronOptionsDefaultsinjs/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?
-
@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.jsand send data tomodulewithsendSocketNotification(). 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 :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login