Skip to content
Advertisement

How we can intergrate Qr code monkey api to an express.js backend

Intergrate this for https://rapidapi.com/qrcode-monkey/api/custom-qr-code-with-logo

For this code

const express = require(‘express’); const http = require(“https”);

const router = express.Router();

router.post(‘/’,async (req,res)=>{

console.log(“req”,req.body);

return res.sendStatus(200);

});

module.exports = router;

Advertisement

Answer

I’m not sure the question you’re asking here.

My guess is that you’re trying to interact with the qrcode-monkey API using express.js?

If that’s true, following the qrcode-monkey API documentation you’ll have to invoke (in this case) express to issue either a GET or POST request to the correct end point /qr/transparent with the required data both in the request body and head. this is documented in the link you provided

since you’re doing this via express it’s I assume you’re going to be passing the URL that the qr code points to via your endpoint then to the 3rd party API. This might looking something like this.

router.get('/:url', async (req, res, next) => {
    if (!req.params.url) next(new Error('400 missing url param'))
    try {
        res.body.qr = await fetch('https://qrcode-monkey.p.rapidapi.com/qr/transparent',
            {
              method: 'GET',
              headers: { ... },
              body: { ... }
            }
         ).json()
    } catch (error) {
        next(error)
    }
    res.json(req.body.qr)
})

note: this is pesudo code and shouldn’t just be copy/pasted.


I suggest refering to the express.js documentation

This question seems to go into more detail about 3rd party API interation with express.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement