How to read a query parameter in Netlify Edge function

Posted on October 20, 2022

Here the function example:

export default async (request, context) => {

    const url = new URL(request.url)
    
    const u = url.searchParams.get("u")

    return new Response(JSON.stringify({myParam: u}), {
        headers: { 'content-type': 'application/json' }
    })
}