Skip to content

Commit 7092e4d

Browse files
feat: remove ky in favor of fetch
1 parent ae19527 commit 7092e4d

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"fathom-client": "^3.4.1",
3737
"got": "^12.0.3",
3838
"isomorphic-unfetch": "^3.1.0",
39-
"ky": "^0.31.4",
4039
"lqip-modern": "^1.2.0",
4140
"next": "^12.3.1",
4241
"notion-client": "^6.15.6",

pages/api/social-image.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22
import { NextRequest } from 'next/server'
33

44
import { ImageResponse } from '@vercel/og'
5-
import ky from 'ky'
65

76
import { api, apiHost } from '@/lib/config'
87
import { NotionPageInfo } from '@/lib/types'
@@ -31,11 +30,17 @@ export default async function OGImage(req: NextRequest) {
3130
return new Response('Invalid notion page id', { status: 400 })
3231
}
3332

34-
const pageInfo = await ky
35-
.post(`${apiHost}${api.getNotionPageInfo}`, {
36-
json: { pageId }
37-
})
38-
.json<NotionPageInfo>()
33+
const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, {
34+
method: 'POST',
35+
body: JSON.stringify({ pageId }),
36+
headers: {
37+
'content-type': 'application/json'
38+
}
39+
})
40+
if (!pageInfoRes.ok) {
41+
return new Response(pageInfoRes.statusText, { status: pageInfoRes.status })
42+
}
43+
const pageInfo: NotionPageInfo = await pageInfoRes.json()
3944
console.log(pageInfo)
4045

4146
return new ImageResponse(

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,11 +2233,6 @@ keyv@^4.0.0:
22332233
compress-brotli "^1.3.6"
22342234
json-buffer "3.0.1"
22352235

2236-
ky@^0.31.4:
2237-
version "0.31.4"
2238-
resolved "https://registry.yarnpkg.com/ky/-/ky-0.31.4.tgz#c629a707053a92611cefa23079a0b0b60131b4b4"
2239-
integrity sha512-OFuAD3riwhAfHK3J4FrhlujFRpm0ELBEfDHZfFpw89OTozQt3NLF39lNblUO5udj5vSkyaBKnLai/rFCzBfISQ==
2240-
22412236
levn@^0.4.1:
22422237
version "0.4.1"
22432238
resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"

0 commit comments

Comments
 (0)