Browse Source

make Prettier (v2)

json-url-form
AJ ONeal 3 years ago
parent
commit
9395ec96e3
  1. 11
      examples/follow-redirect.js
  2. 11
      examples/no-follow-redirect.js

11
examples/follow-redirect.js

@ -5,11 +5,9 @@ var request = require('../');
// will redirect to https://www.github.com and then https://github.com
//request('http://www.github.com', function (error, response, body) {
request({ uri: { protocol: 'http:', hostname: 'www.github.com' } }, function(
error,
response,
body
) {
request(
{ uri: { protocol: 'http:', hostname: 'www.github.com' } },
function (error, response, body) {
if (error) {
console.log('error:', error); // Print the error if one occurred
return;
@ -17,4 +15,5 @@ request({ uri: { protocol: 'http:', hostname: 'www.github.com' } }, function(
console.log('statusCode:', response.statusCode); // The final statusCode
console.log('Final href:', response.request.uri.href); // The final URI
console.log('Body Length:', body.length); // body length
});
}
);

11
examples/no-follow-redirect.js

@ -4,11 +4,9 @@
var request = require('../');
// would normally redirect to https://www.github.com and then https://github.com
request({ uri: 'https://www.github.com', followRedirect: false }, function(
error,
response,
body
) {
request(
{ uri: 'https://www.github.com', followRedirect: false },
function (error, response, body) {
if (error) {
console.log('error:', error); // Print the error if one occurred
return;
@ -17,4 +15,5 @@ request({ uri: 'https://www.github.com', followRedirect: false }, function(
console.log('statusCode:', response.statusCode); // Should be 301 or 302
console.log('Location:', response.headers.location); // The redirect
console.log('Body:', body || JSON.stringify(body));
});
}
);

Loading…
Cancel
Save