-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
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
Labels
No labels