Suggestion on how to add a custom request function

I am currently using a custom function that wraps the app.request.post() method, but I think there must be a better way to setup this function. Currently I’m defining the method like so:

// in my app.f7.html

export default {
    mounted() {
        var self = this;
        var app = self.$app;
        
        self.$f7ready(() => {
            app.request.customPost = async (endpoint, payload, success, error) => {
                payload['customField'] = 'somethingCustom'
                app.request.post(endpoint, payload)
            })
        }
    }
}

Is there a better way to create a custom wrapper for this function?

This is the same way I do it for long time, think it’s just the correct way to do it. There is a method to setup ajax defaults, but it’s use is not recommended :slight_smile:

https://framework7.io/docs/request.html#request-setup

1 Like