Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Do I Use This In A Serverless App? #1690

Closed
influential-eliot opened this issue Oct 21, 2024 · 1 comment
Closed

How Do I Use This In A Serverless App? #1690

influential-eliot opened this issue Oct 21, 2024 · 1 comment

Comments

@influential-eliot
Copy link

What are you working on?

I'm trying to use this in some code which is running in an online serverless app and therefor am wanting to avoid using 'import' ... in case I have to make many requests, as I don't wish to throttle anything.

How would I (for example) copy paste the code into mine so that it could be used like that?

Sorry, I don't know much about javascript, and I'm fumbling a little, here!

But basically, no matter how I have the code, even if I do use "import" to a file on the same cloud server, I cannot get it to work. I'm not really looking to find solutions for specific errors, I'm more wanting to know if there is a simpler way that I can go about this.

Additional Notes

Let's assume I have something like this:

module.exports = async function (context, req) {
    const pdfBase64 = req.body.fileContentBase64;
    let pdfDoc = await PDFDocument(pdfBase64);
    let form = pdfDoc.getForm();

    context.res = {
        "headers": {
            "Content-Type": "application/json"
        },
        "body": {
            "formData": form
        }
    };
};

I've tried pasting the entire code, the minified code, putting the file in the same folder (or others) and using import both inside and outside the 'module.exports' stuff ... nothing has any joy. 😩

@influential-eliot
Copy link
Author

OK, I've moved the 'importing' inside the module ... but it's as a const/require ... and I'm getting some other errors. I'll raise them separately.

I'd say this is worked-around, rather than fixed. 👍


FWIW - When I say 'serverless' I'm referring to the type of blue which a large multinational tech firm has named their cloud based organisational tech services and within that their apps which are more functional than logical. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant