Skip to content

Commit

Permalink
feat: remove ky in favor of fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Oct 18, 2022
1 parent ae19527 commit 7092e4d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"fathom-client": "^3.4.1",
"got": "^12.0.3",
"isomorphic-unfetch": "^3.1.0",
"ky": "^0.31.4",
"lqip-modern": "^1.2.0",
"next": "^12.3.1",
"notion-client": "^6.15.6",
Expand Down
17 changes: 11 additions & 6 deletions pages/api/social-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react'
import { NextRequest } from 'next/server'

import { ImageResponse } from '@vercel/og'
import ky from 'ky'

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

const pageInfo = await ky
.post(`${apiHost}${api.getNotionPageInfo}`, {
json: { pageId }
})
.json<NotionPageInfo>()
const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, {
method: 'POST',
body: JSON.stringify({ pageId }),
headers: {
'content-type': 'application/json'
}
})
if (!pageInfoRes.ok) {
return new Response(pageInfoRes.statusText, { status: pageInfoRes.status })
}
const pageInfo: NotionPageInfo = await pageInfoRes.json()
console.log(pageInfo)

return new ImageResponse(
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2233,11 +2233,6 @@ keyv@^4.0.0:
compress-brotli "^1.3.6"
json-buffer "3.0.1"

ky@^0.31.4:
version "0.31.4"
resolved "https://registry.yarnpkg.com/ky/-/ky-0.31.4.tgz#c629a707053a92611cefa23079a0b0b60131b4b4"
integrity sha512-OFuAD3riwhAfHK3J4FrhlujFRpm0ELBEfDHZfFpw89OTozQt3NLF39lNblUO5udj5vSkyaBKnLai/rFCzBfISQ==

levn@^0.4.1:
version "0.4.1"
resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
Expand Down

0 comments on commit 7092e4d

Please sign in to comment.