1.3.34 • Published 3 months ago

get-remote v1.3.34

Weekly downloads
41
License
MIT
Repository
github
Last release
3 months ago

get-remote

Download a text, json, a file with optional extract, get a stream, or head an endpoint.

Callbacks

var assert = require('assert')
var get = require('get-remote'))

// get stream
get('http://api.com/fixture.json').stream(function (err, stream) {
  // do something
});

// get and extract
get('http://api.com/fixture.tar.gz').extract(process.cwd(), { strip: 1 }, function (err) {
  // do something
});

// get to file with inferred name of 'fixture.json'
get('http://api.com/fixture.json').file(process.cwd(), function (err) {
  // do something
});

// head the endpoint
get('http://api.com/fixture.json').head(function (err, res) {
  assert.equal(res.statusCode, 200);
  assert.ok(!!res.headers);
});

// get json
get('http://api.com/fixture.json').json(function (err, res) {
  assert.ok(!!res.headers);
  assert.ok(!!res.statusCode);
  assert.ok(!!res.body);
  // do something with res.body
});

// pipe to write stream
get('http://api.com/fixture.json').pipe(fs.createWriteStream(path.join(process.cwd(), 'fixture.json')), function (err) {
  // do someting
});

// get text
get('http://api.com/fixture.text').text(function (err, res) {
  assert.ok(!!res.headers);
  assert.ok(!!res.statusCode);
  assert.ok(!!res.body);
  // do something with res.body
});


// get and extract - callbacks
get('https://cdn.jsdelivr.net/gh/nodejs/Release@main/schedule.json').extract(fullPath, { strip: 1 }, function(err) {
  
  // do something
})

Promises

var assert = require('assert')
var get = require('get-remote'))

// get stream
var stream = await get('http://api.com/fixture.json').stream();

// get and extract
await get('http://api.com/fixture.tar.gz').extract(process.cwd(), { strip: 1 });

// get to file with inferred name of 'fixture.json'
await get('http://api.com/fixture.json').file(process.cwd());

// get to file with explicit name of 'get.json'
await get('http://api.com/fixture.json').file(process.cwd(), {filename: 'get.json'});

// head the endpoint
var res = await get('http://api.com/fixture.json').head(function (err, res) {
assert.equal(res.statusCode, 200);
assert.ok(!!res.headers);

// get json
var res = await get('http://api.com/fixture.json').json();
assert.ok(!!res.headers);
assert.ok(!!res.statusCode);
assert.ok(!!res.body);

// pipe to write stream
await get('http://api.com/fixture.json').pipe(fs.createWriteStream(path.join(process.cwd(), 'fixture.json'))));

// get text
var res = await get('http://api.com/fixture.text').text();
assert.ok(!!res.headers);
assert.ok(!!res.statusCode);
assert.ok(!!res.body);
1.3.34

3 months ago

1.3.18

5 months ago

1.3.19

5 months ago

1.3.20

5 months ago

1.3.21

5 months ago

1.3.24

5 months ago

1.3.25

5 months ago

1.3.22

5 months ago

1.3.23

5 months ago

1.3.28

5 months ago

1.3.29

5 months ago

1.3.26

5 months ago

1.3.27

5 months ago

1.3.31

5 months ago

1.3.32

5 months ago

1.3.30

5 months ago

1.3.33

5 months ago

1.3.17

5 months ago

1.3.15

5 months ago

1.3.16

5 months ago

1.3.13

5 months ago

1.3.14

5 months ago

1.3.11

5 months ago

1.3.12

5 months ago

1.2.3

6 months ago

1.3.10

5 months ago

1.3.9

5 months ago

1.3.8

5 months ago

1.3.7

5 months ago

1.3.6

5 months ago

1.3.5

5 months ago

1.3.4

5 months ago

1.3.3

5 months ago

1.3.2

6 months ago

1.3.1

6 months ago

1.3.0

6 months ago

1.2.0

6 months ago

1.2.2

6 months ago

1.2.1

6 months ago

1.1.0

6 months ago

1.0.2

6 months ago

1.0.1

7 months ago

1.0.0

7 months ago

0.8.4

1 year ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.0

3 years ago

0.7.11

3 years ago

0.7.10

3 years ago

0.7.9

3 years ago

0.7.12

3 years ago

0.7.6

3 years ago

0.7.5

3 years ago

0.7.8

3 years ago

0.7.7

3 years ago

0.8.1

3 years ago

0.6.3

3 years ago

0.8.0

3 years ago

0.6.2

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.15

5 years ago

0.4.13

5 years ago

0.4.14

5 years ago

0.4.12

5 years ago

0.4.11

5 years ago

0.4.10

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.6

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago