File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
components/ExpandableContributorList Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -250,6 +250,11 @@ export class Api {
250250 return contributors ;
251251 }
252252
253+ async fetchAllContributorsFromClient ( ) : Promise < Contributor [ ] > {
254+ const res = await fetch ( 'api/contributors' ) ;
255+ return ( await res . json ( ) ) . contributors ;
256+ }
257+
253258 async fetchNpmInfo ( npmId : string ) : Promise < NpmInfo | null > {
254259 try {
255260 const npmApiUrl = 'https://registry.npmjs.org/' ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const getComponent = async () => {
2020} ;
2121
2222const getComponentProps = async ( ) => {
23- const contributors = await Api . instance . fetchAllContributorsWithCache ( ) ;
23+ const contributors = await Api . instance . fetchAllContributorsFromClient ( ) ;
2424
2525 return { contributors} ;
2626} ;
Original file line number Diff line number Diff line change 1+ import type { NextApiRequest , NextApiResponse } from 'next' ;
2+ import { Api } from 'src/api' ;
3+
4+ export default async function handler ( req : NextApiRequest , res : NextApiResponse ) {
5+ if ( req . method !== 'GET' ) {
6+ res . setHeader ( 'Allow' , [ 'GET' ] ) ;
7+ res . status ( 405 ) . end ( `Method ${ req . method } Not Allowed` ) ;
8+ return ;
9+ }
10+
11+ const contributors = await Api . instance . fetchAllContributorsWithCache ( ) ;
12+
13+ res . status ( 200 ) . json ( { contributors} ) ;
14+ }
You can’t perform that action at this time.
0 commit comments