Skip to content

Query Parameter

TIP

You only need to read this page when NOT using our JS SDK.

Most of our API endpoints support both GET and POST. Sometimes you need to provide an object or an array when calling our API, and it's easy if you're doing POST requests, since the request body is just a JSON:

ts
fetch(`https://api.browserku.com`, {
  method: "POST",
  body: JSON.stringify({
    url: "https://example.com",
    pdf: {
      margin: {
        top: "1cm",
        bottom: "1cm",
      },
    },
  }),
})

When doing GET requests, you can use dot-nested syntax to set object instead:

?pdf.margin.top=1cm&pdf.margin.bottom=1cm

..and [index] syntax to set an array:

?styles[0]=body{color:red}

If you want construct the URL programmatically, you can also directly provide it as a JSON string:

ts
const pdf = JSON.stringify({
  margin: {
    top: "1cm",
    bottom: "1cm",
  },
})

const query = `?pdf=${pdf}`