node.js - Request: How to set user agent for every request? -


using request possible set user agent every request?

currently have set @ time of making request:

request.post(url, { form: form, headers: { 'user-agent': ua }}, function(err, resp, body) {     // stuff }) 

is possible?

you can create request method own defaults:

var customheaderrequest = request.defaults({     headers: {'user-agent': ua} }) 

then use it:

customheaderrequest.post(url) 

see https://www.npmjs.com/package/request#requestdefaultsoptions


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -