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
Post a Comment