![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | lib/ | 2 years ago | - | |
![]() | test/ | 2 years ago | - | |
![]() | CHANGELOG.md | 9 years ago | 476 | |
![]() | Gruntfile.js | 9 years ago | 593 | |
![]() | LICENSE | 9 years ago | 935 | |
![]() | README.md | 9 years ago | 2.5K | |
![]() | package.json | 2 years ago | 1.6K |
Fetches HTTP URL contents for nodemailer.
var fetch = require('nodemailer-fetch');
fetch('http://www.google.com/').pipe(process.stdout);
The method takes the destination URL as the first and optional options object as the second argument.
The defaults are the following:
tls
optionPossible options are the following:
userAgent a string defining the User Agent of the request (by default not set)
cookie a cookie string or an array of cookie strings where a cookie is the value used by 'Set-Cookie' header
maxRedirects how many redirects to allow (defaults to 5, set to 0 to disable redirects entirely)
method HTTP method to use, defaults to GET (if body
is set defaults to POST)
body HTTP payload to send. If the value is an object it is converted to an x-www-form-urlencoded payload, other values are passed as is. Unlike authentication data payload and method is preserved between redirects
contentType optional content type for the HTTP payload. Defaults to x-www-form-urlencoded. If the value is false
then Content-Type header is not set
tls optional object of TLS options
timeout (milliseconds) sets timeout for the connection. Returns an error if timeout occurs
headers custom headers as an object where key is the header key and value is either a string or an array of strings for multiple values
var fetch = require('nodemailer-fetch');
fetch('http://www.google.com/', {
cookie: [
'cookie_name1=cookie_value1',
'cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT',
],
userAgent: 'MyFetcher/1.0'
}).pipe(process.stdout);
Cookies are domain specific like normal browser cookies, so if a redirect happens to another domain, then cookies are not passed to it, HTTPS-only cookies are not passed to HTTP etc.
MIT