mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-19 00:26:34 +08:00
16 lines
453 B
TypeScript
16 lines
453 B
TypeScript
import * as fs from 'fs';
|
|
import * as util from 'util';
|
|
import * as snekfetch from 'snekfetch';
|
|
|
|
const writeFile = util.promisify(fs.writeFile);
|
|
|
|
snekfetch.get('https://s.gus.host/o-SNAKES-80.jpg')
|
|
.then(r => writeFile('download.jpg', r.body));
|
|
|
|
snekfetch.get('https://s.gus.host/o-SNAKES-80.jpg')
|
|
.pipe(fs.createWriteStream('download.jpg'));
|
|
|
|
snekfetch.post('https://httpbin.org/post')
|
|
.send({ meme: 'dream' })
|
|
.then(r => console.log(r.body));
|