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

Add Promise Support for transformRequest #86

Open
WatchfulEyeOfZod opened this issue Dec 18, 2024 · 0 comments
Open

Add Promise Support for transformRequest #86

WatchfulEyeOfZod opened this issue Dec 18, 2024 · 0 comments

Comments

@WatchfulEyeOfZod
Copy link

The ability to override the request to the backend is very powerful, however, it currently does not allow the use of async/await which is required for overriding some calls to the back end.

I am currently working on supporting a serverless AWSnLambda / AWS S3 backend for this and one when attempting to upload files, I need to make a request to the lambda to get a tempoary signedURL to use as an upload target. However, because this method does not support async, there is no way to do this . For example:

const request = {
        baseUrl: "https://my-lambda-url-in-aws/backend",
        transformRequest: req => {
            if(req.params?.q === "upload") {
                // Go Get a Temporary S3_signed_url from the backend Lambda
                // Does not work because this function does not support async
                // const result = await getUploadURL(req.params.path)
                // req.url = result.url
                // req.method = 'post'
                // req.body = result.fields
            } 
            return req;
        },
    }     

The solution (I think) would be to adjust ajax.js (here

const transformResult = config.transformRequest({
) and make this method await and accept a promise result before continuing...

Thanks! Great work on the vuefinder. This is a much needed component.

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

No branches or pull requests

1 participant