imagekit-developer / imagekit-nodejs

Node.js SDK for ImageKit.io API.
https://imagekit.io
Other
84 stars 32 forks source link

Uncaught TypeError: url_1.URLSearchParams is not a constructor #97

Closed veeresh2022 closed 1 month ago

veeresh2022 commented 4 months ago

we are trying to implement cropping tool using image kit. with below code

const params = {
        width: completedCrop.width,
        height: completedCrop.height,
        x: completedCrop.x,
        y: completedCrop.y,
      }
      const imgURL = imagekit.url({
        src: imageUrl,
        transformation: [params],
      })

imagekit is an object of ImageKit(...) with private and public keys.

React Version: 18.2.0 Node version: 18.20.1 imagekit version: 5.0.1

ankur-dwivedi commented 3 months ago

Hi @veeresh2022 could you please share you TypeScript version and tsconfig.json file to replicate the issue. Also, if you intend to crop an image, you might be missing some properties. Using only x and y alone will not help you can use cropMode with it. Refer the below code.

const params = {
  width: completedCrop.width,
  height: completedCrop.height,
  x: completedCrop.x,
  y: completedCrop.y,
  cm: "extract"
}

const imgURL = imagekit.url({
  src: imageUrl,
  transformation: [params],
})

For more information on ImageKit cropping, refer the docs.