I am using the 'html-pdf' npm package to create a byte array in a nodeJs azure function. I can log and see that the byte array is being created but when i call my function i cannot get the buffer to return. My response is a 200 and again i can see the buffer if i log it to string. For context the package takes an html string and returns a pdf .How do i set the response to return the byte array?
var pdf = require('html-pdf');
module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    if ((req.body && req.body.data)) {
        var html = req.body.data;
        context.log(html);
        console.log(html);
        var data = []
         pdf.create(html).toBuffer(function(err, buffer){
            data.push(buffer);
            context.res = {
                setEncoding: 'binary',
                // status: 200, /* Defaults to 200 */
                body: Buffer.concat(data)
            };
          });
    }
    else {
        context.res = {
            status: 400,
            body: "Please pass a name on the query string or in the request body"
        };
    }
};
 
    
