Skip to content

Commit

Permalink
docs: add examples to fetch/request (nodejs#1287)
Browse files Browse the repository at this point in the history
* docs: add examples to fetch/request

* fix: lint
  • Loading branch information
RafaelGSS authored and metcoder95 committed Dec 26, 2022
1 parent cb449b5 commit 7e83e92
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/fetch.js
@@ -0,0 +1,13 @@
'use strict'

const { fetch } = require('../')

async function main () {
const res = await fetch('http://localhost:3001/')

const data = await res.text()
console.log('response received', res.status)
console.log('headers', res.headers)
console.log('data', data)
}
main()
18 changes: 18 additions & 0 deletions examples/request.js
@@ -0,0 +1,18 @@
'use strict'

const { request } = require('../')

async function main () {
const {
statusCode,
headers,
body
} = await request('http://localhost:3001/')

const data = await body.text()
console.log('response received', statusCode)
console.log('headers', headers)
console.log('data', data)
}

main()

0 comments on commit 7e83e92

Please sign in to comment.