Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
chore: remove headers from undici example
Browse files Browse the repository at this point in the history
  • Loading branch information
hanspagel committed Dec 12, 2023
1 parent 020d0cb commit 54bda26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const snippet = snippetz().get(
/* Output */

// import { request } from 'undici'
// const { statusCode, headers, body } = await request(
// const { statusCode, body } = await request(
// 'https://example.com',
// )
```
Expand All @@ -52,7 +52,7 @@ console.log(source.code)

// import { request } from 'undici'

// const { statusCode, headers, body } = await request(
// const { statusCode, body } = await request(
// 'url': 'https://example.com',
// )
```
Expand Down
12 changes: 6 additions & 6 deletions packages/snippetz-plugin-undici/src/undici.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('undici', () => {

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com')
const { statusCode, body } = await request('https://example.com')
`)
})

Expand All @@ -29,7 +29,7 @@ const { statusCode, headers, body } = await request('https://example.com')

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com', {
const { statusCode, body } = await request('https://example.com', {
method: 'POST'
})
`)
Expand All @@ -48,7 +48,7 @@ const { statusCode, headers, body } = await request('https://example.com', {

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com', {
const { statusCode, body } = await request('https://example.com', {
headers: {
'Content-Type': 'application/json'
}
Expand All @@ -75,7 +75,7 @@ const { statusCode, headers, body } = await request('https://example.com', {

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com', {
const { statusCode, body } = await request('https://example.com', {
headers: {
'Content-Type': 'application/json'
},
Expand Down Expand Up @@ -109,7 +109,7 @@ const { statusCode, headers, body } = await request('https://example.com', {

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com?foo=bar&bar=foo', {
const { statusCode, body } = await request('https://example.com?foo=bar&bar=foo', {
headers: {
'Content-Type': 'application/json'
}
Expand All @@ -134,7 +134,7 @@ const { statusCode, headers, body } = await request('https://example.com?foo=bar

expect(source.code).toBe(`import { request } from 'undici'
const { statusCode, headers, body } = await request('https://example.com', {
const { statusCode, body } = await request('https://example.com', {
headers: {
'Set-Cookie': 'foo=bar; bar=foo'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/snippetz-plugin-undici/src/undici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function undici(request: Partial<Request>): Source {
// Code Template
const code = `import { request } from 'undici'
const { statusCode, headers, body } = await request('${normalizedRequest.url}${queryString}'${jsonOptions})
const { statusCode, body } = await request('${normalizedRequest.url}${queryString}'${jsonOptions})
`

// Create an AST
Expand Down

0 comments on commit 54bda26

Please sign in to comment.