How to send request to url address using net module node js - javascript

How to send a simple get/post request to a URL using the net module?
I want to send a request using the net module, because I heard that the net module is faster than other modules, such as “request”, “http” and others, but more difficult to implement

Related

Routing traffic in docker

I'm running integration tests on several AWS Lambda's and I need a way to route API calls to a dummy express server on my local machine. Normally I would just change the url's of the API calls, but the urls are generated in projects that are not apart of this and imported via npm, so hardcoding in a new url isn't practical.
My goal is to have these modules use the URL generated but have that routed to a dummy Express server that I'am running where I will have prepackaged responses so I can test the functionality of these lambdas. For example there is a request for an authorization token from an outside service. Instead of requesting from the actual service it would be routed to my local express server which would just provide a static authorization token. There is then another point where that token is verified and I would again hope that this would get routed to the same server (though in reality it's a different service) and it would verify the token.
Ultimately I will have this dummy Express server, a DynamoDB, and SQS, running on docker containers locally to essentially imitate this software running live.
I've seen that docker can route traffic, but I'm not sure if what I'm attempting to do will be possible. I've googled around but most of the stuff I have found seems a bit more simple then what I'm attempting.

HTTPS Post request in Ionic 3

I'm working on an Ionic 3 application which requires me to send encrypted data over internet to AWS lambda function. I have a API created for this lambda function and I'm able to send a post request to the lambda function using ionic's http plugin. But we can easily track the post requests send from the current configuration of my application in the Network logs.
So how can I send my data from app to AWS lambda function in a secured way?
I read about the SSLpinning in http plugin but is this the only way to approach the issue?
The problem with encrypting in the app is, that it's not that hard to make reverse enginering to see how it is made.
It's a little harder to crack if you get a key from the server at login (or daily) and use this for encrypting.
https://ionicframework.com/docs/native/aes256/
I am pretty sure you can find other pre-made modules. Else make your own. Hackers hate custom design.
And btw - https-communication to be sure it's actual is you the app is talking to.

How to get data from node.js server into Electron app?

My question is about:
I am currently trying to connect my electron application to my node server to get data from node.js server and print that data to my electron application. However I don't know how to do it. So could anyone help me:
To get data from node.js server into electron app?
The way you get data from any node.js server is you make a request to that server specifying in the request what you're asking for and the server responds with the appropriate data.
There are literally thousands of ways to physically make the request. The classic way in these days of web technologies is to make an http request from your electron app to an http server in your node.js server. You can make such a request from electron using the request() library.
You would then have an http server as part of your node.js server and you'd specify routes in that http server that handle the requests your electron client is making, fetch the desired data and send the data back as the response. In the node.js world, you can create a simple http server and a few request handlers in a dozen lines of code using the Express library.
This is the general approach. Further details on the exact request to make and URLs to use are dependent upon the details of what you're trying to do and the design you choose, none of which you've shared with us.

MEAN API request method questions

I'am reading the 'Getting MEAN with mongo, express, angular and node' book made by Simon Holmes. I like it alot but i had a big question which doesn't Seems to be covered in the book, he is talking about rest-api through http request (i went a bit forward in the book and saw there was a login system) and that triggered me a bit isn't it risky to do everything in http. And my other question was when you load your rest api in Heroku (and all your website) are the request in https since they force https (i know it cause i couldnt load Google font due to me making the request in http)
isn't it risky to do everything in http
It's less secure. People can read any request in plain text.
when you load your rest api in Heroku (and all your website) are the
request in https
Whist you can use HTTP, you can make any request over HTTPS with no cost. When you upload your real app you will also want to configure your server to redirect to HTTPS too.

SOAP Web Services in NativeScript

I am new in nativescript app development, I want to use SOAP web services in nativescript, i.e how to implement SOAP request & response in nativescript. Please give me suggestions, didn't find any way to implement SOAP, all search results are implemented in JavaScript code.
I do open github issues, please check - https://github.com/NativeScript/NativeScript/issues/2284
Thanks :)
Well, their is no built in soap handling. However, you can make you own in a couple steps.
NativeScript has built in http requests, and XMLHttpRequest and Fetch; this means you can query and receive back data you want from any service url. http://docs.nativescript.org/api-reference/modules/http.html, https://docs.nativescript.org/cookbook/fetch, http://docs.nativescript.org/cookbook/http
In addition, their is a third party plugin called nativescript-apiclient which makes it easier to deal with http requests with changing parameters. (i.e. http://somewhere/getdata/{token}/{data} where you can just pass in a token and data value...) See http://plugins.nativescript.rocks for different plugins available.
NativeScript has a XML parser built in, Soap responses are typically XML based. So you can easily instantiate the xml engine to parse your soap requests (http://docs.nativescript.org/cookbook/xml-parser)

Categories

Resources