1.3.34 • Published 8 months ago

get-remote v1.3.34

Weekly downloads
41
License
MIT
Repository
github
Last release
8 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

8 months ago

1.3.18

9 months ago

1.3.19

9 months ago

1.3.20

9 months ago

1.3.21

9 months ago

1.3.24

9 months ago

1.3.25

9 months ago

1.3.22

9 months ago

1.3.23

9 months ago

1.3.28

9 months ago

1.3.29

9 months ago

1.3.26

9 months ago

1.3.27

9 months ago

1.3.31

9 months ago

1.3.32

9 months ago

1.3.30

9 months ago

1.3.33

9 months ago

1.3.17

9 months ago

1.3.15

9 months ago

1.3.16

9 months ago

1.3.13

9 months ago

1.3.14

9 months ago

1.3.11

9 months ago

1.3.12

9 months ago

1.2.3

10 months ago

1.3.10

10 months ago

1.3.9

10 months ago

1.3.8

10 months ago

1.3.7

10 months ago

1.3.6

10 months ago

1.3.5

10 months ago

1.3.4

10 months ago

1.3.3

10 months ago

1.3.2

10 months ago

1.3.1

10 months ago

1.3.0

10 months ago

1.2.0

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.1.0

10 months ago

1.0.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.8.4

2 years 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