From 27134c0ab943233f2f7265e9f46529aa593fbd96 Mon Sep 17 00:00:00 2001 From: Mohit Yadav Date: Fri, 12 Jan 2024 12:18:08 -0500 Subject: [PATCH 1/4] docs: make awaited function async --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75b9603f8..945463609 100644 --- a/README.md +++ b/README.md @@ -434,7 +434,7 @@ import { fetch } from 'undici'; // as one example import OpenAI from 'openai'; const client = new OpenAI({ - fetch: (url: RequestInfo, init?: RequestInfo): Response => { + fetch: async (url: RequestInfo, init?: RequestInfo): Response => { console.log('About to make request', url, init); const response = await fetch(url, init); console.log('Got response', response); From 041f2a6359293419c6dbf72c0e1e7a8c1b50e1e7 Mon Sep 17 00:00:00 2001 From: Mohit Yadav Date: Fri, 12 Jan 2024 12:19:23 -0500 Subject: [PATCH 2/4] docs: make return generic --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 945463609..8353cf487 100644 --- a/README.md +++ b/README.md @@ -434,7 +434,7 @@ import { fetch } from 'undici'; // as one example import OpenAI from 'openai'; const client = new OpenAI({ - fetch: async (url: RequestInfo, init?: RequestInfo): Response => { + fetch: async (url: RequestInfo, init?: RequestInfo): => { console.log('About to make request', url, init); const response = await fetch(url, init); console.log('Got response', response); From 8438c2c79229448b21f9b92b07e37b98ba88ea80 Mon Sep 17 00:00:00 2001 From: Mohit Yadav Date: Fri, 12 Jan 2024 12:19:47 -0500 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8353cf487..945463609 100644 --- a/README.md +++ b/README.md @@ -434,7 +434,7 @@ import { fetch } from 'undici'; // as one example import OpenAI from 'openai'; const client = new OpenAI({ - fetch: async (url: RequestInfo, init?: RequestInfo): => { + fetch: async (url: RequestInfo, init?: RequestInfo): Response => { console.log('About to make request', url, init); const response = await fetch(url, init); console.log('Got response', response); From 0cfb8a0f8fb58de248d80332bbc20055269d2f84 Mon Sep 17 00:00:00 2001 From: Mohit Yadav Date: Fri, 12 Jan 2024 12:20:35 -0500 Subject: [PATCH 4/4] docs: make return a promise, fix accidental commit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 945463609..6464ab4c0 100644 --- a/README.md +++ b/README.md @@ -434,8 +434,8 @@ import { fetch } from 'undici'; // as one example import OpenAI from 'openai'; const client = new OpenAI({ - fetch: async (url: RequestInfo, init?: RequestInfo): Response => { - console.log('About to make request', url, init); + fetch: async (url: RequestInfo, init?: RequestInfo): Promise => { + console.log('About to make a request', url, init); const response = await fetch(url, init); console.log('Got response', response); return response;