Skip to content

Get QR code SDK not correct #196

@gianniskotsas

Description

@gianniskotsas

Path: /api-reference/endpoint/retrieve-a-qr-code

I am using NextJS and Typescript. I have a URL that i want to retrieve its QR code. Using the implementation from the docs, this is suggested:

 const dub = new Dub({
      token: process.env.DUB_API_KEY!,
    });

    const image = await dub.qrCodes.get({ url });

Although in the docs it is stated that I retrieve a string back, initially I assumed it would be base64 and tried to decode it, then I saw that it is PNG and tried to convert it from binary. Nothing worked. I have a feeling that the string we get back from the SDK is not correct. If it is, can you please let us know how to save the string we get back as an image?

My current workaround is using the following fetch request:

const apiUrl = `https://api.dub.co/qr?url=${url}`;
    const response = await fetch(apiUrl, {
      method: "GET",
      headers: {
        Authorization: `Bearer ${process.env.DUB_API_KEY}`,
        Accept: "image/png",
      },
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions