#Can't access searchParams

8 messages · Page 1 of 1 (latest)

fast pivot
#

I'm trying to read the search params in this URL: /api/getblogs?limit=5

export const get: APIRoute = async function get({ request }) {
    const urlData = new URL(request.url);
    console.log(urlData);

    // other code
}

The console.log() logs the following:

URL {
  href: 'http://127.0.0.1:3001/api/getblogs',
  origin: 'http://127.0.0.1:3001',
  protocol: 'http:',
  username: '',
  password: '',
  host: '127.0.0.1:3001',
  hostname: '127.0.0.1',
  port: '3001',
  pathname: '/api/getblogs',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

The searchParams property is empty, am I doing something wrong?

stoic hazel
#

Are you in SSG mode?

fast pivot
#

Yes

ruby osprey
fast pivot
#

Is there a way to run js on the client after it build?

ruby osprey
fast pivot
#

Inside a TS file for endpoints

ruby osprey