4

I have a node.js server running on a VPS and I want to use a js script that is served from another server, something like:

http://example.com/api/js

How do I load this script and use it in my node.js file?

Thanks!

gsobrevilla
  • 243
  • 2
  • 12
  • Maybe download the script and then copy paste it into your file? Otherwise check this http://stackoverflow.com/questions/4481058/load-and-execute-external-js-file-in-node-js-with-access-to-local-variables – theodore hogberg Aug 30 '14 at 17:06

1 Answers1

4

exec('wget http://example.com/api/js', function(stdout) { }); should do the trick. If you need advanced control, use http module.

H.Sarxha
  • 157
  • 1
  • 9
eguneys
  • 6,028
  • 7
  • 31
  • 63