Skip to content

Patch superagent to add headers or queries to each request to a given host

License

Notifications You must be signed in to change notification settings

founderlab/superagent-request-modifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

superagent-request-modifier

Patch superagent to add headers or queries to each request on a given host.

Use this to e.g. send access tokens with mobile api requests

Usage:
import request from 'superagent'
import configureModifier from 'superagent-request-modifier'

// All requests to localhost will have {access_token: 'asdf1234'} added as a header
configureModifier(request, {hostname: 'localhost', headers: {access_token: 'asdf1234'}})

// All requests to example.com will have ?access_token="asdf1234" added to the url as a query string
configureModifier(request, {hostname: 'example.com', query: {access_token: 'asdf1234'}})

About

Patch superagent to add headers or queries to each request to a given host

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published