Edits history of script submission #17915 for ' Mark a notification group as read (phrase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Phrase = {
    	token: string
    	baseUrl: string
    }
    /**
     * Mark a notification group as read
     * Mark a notifications group of the current user as read
     */
    export async function main(auth: Phrase, id: string) {
    	const url = new URL(`${auth.baseUrl}/notification_groups/${id}/mark_as_read`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			Authorization: 'ApiToken ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago