const filters = { comments : '!SWJ_S9Hse(rWelcqk1' , questions : '!5RCI6qPDF8)WPM-vVxWYF-1w0' , } ; const thisSite = window . location . hostname . replace ( /\.\w+$/ , '' ) . replace ( /\.stackexchange$/ , '' ) ; const defaultParamsArr = [ [ 'key' , ')b5jvgz1hz0gdK)*4WvlPA((' ] , [ 'site' , thisSite ] , ] ; export const getApi = async < T extends 'comments' | 'questions' > ( method , ids ) => { if ( ! ids . length ) { return { items : [ ] } ; } const searchParams = new URLSearchParams ( defaultParamsArr ) ; searchParams . set ( 'filter' , filters [ method ] ) ; const paramsString = `?${ searchParams . toString ( ) }` ; const url = `https://api.stackexchange.com/2.2/${ method }/${ ids . join ( ';' ) }${ paramsString }` ; const response = await fetch ( url ) ; const responseObj = await response . json ( ) ; return responseObj as T extends 'comments' ? ApiComments : ApiQuestions ; } ;