2

Is it possible to perform GET/POST request in NodeJS using specific network interface?

I.e. with CURL I can invoke two POST calls like:

curl -X POST --interface wlan0 http://192.168.1.5/resource
curl -X POST --interface wlan1 http://192.168.1.5/resource
//                       ^^^^^

Both IP addresses are different machines - so first WiFi module is connected to one SSID, second is connected with a very different network, but the IPs are equal because of some top requirements (they lay in different, isolated networks).

1 Answer 1

6

See the localAddress option in the http options:

You need to set it to your IP address that is used for a given interface.

Another option would be to use node-curl:

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response. But what if both of the sub-networks will assign the same IP for my WiFi adapters? Yeah, node-curl may be my second attempt, but I'd like to handle it in request-way somehow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.