node.js - How do I make this curl call with nodejs request module -
i able send request browsermob using curl so: curl -x put -d "pageref=car" localhost:9000/proxy/8081/har/pageref
. however, inside nodejs using request module. equivalent command using request module? assume request.put(url, data, callback)
when try request.put('localhost:9000/proxy/8081/har/pageref', {form: { pageref: encodeuri(browser.platform) + encodeuri(browser.browsername) + encodeuri(browser.version) }})
, get
error: invalid protocol @ request.self._buildrequest (/users/dragonite/pixel/node_modules/request/request.js:336:53) @ request.init (/users/dragonite/pixel/node_modules/request/request.js:503:10) @ new request (/users/dragonite/pixel/node_modules/request/request.js:97:8) @ request (/users/dragonite/pixel/node_modules/request/index.js:50:11) @ function.request.put (/users/dragonite/pixel/node_modules/request/index.js:121:27) @ repl:1:10 @ replserver.self.eval (repl.js:110:21) @ interface.<anonymous> (repl.js:239:12) @ interface.emit (events.js:95:17) @ interface._online (readline.js:203:10)
it looks missing protocol in front of url like:
request.put('http://localhost:9000/proxy/8081/har/pageref', {form: { pageref: encodeuri(browser.platform) + encodeuri(browser.browsername) + encodeuri(browser.version) }})
Comments
Post a Comment