Stripe Terminal: Invalid `onFetchConnectionToken` handler given

Hello everyone, I hope you all are doing fine. I’m working on Stripe terminal SDK and trying to implement it in ionic v3. I’ve followed the documentation but facing error plus I’ve no idea what i’m doing wrong that error is occuring.

After loading Stripe terminal, when I initialize Stripe SDK by creating stripe terminal I’m calling a function(named as fetchConnectionToken) and return it’s security token but race condition is happening and error pops up.

Screenshot 2021-04-07 at 3.03.48 PM


async initiateStripeTerminal() {
        loadStripeTerminal().then((res) => {
            this.StripeTerminal = res;
        }, (error) => {
            console.log('stripe terminal not loaded', error);

    async initiateStripeTerminalSDK() {
        var terminal = this.StripeTerminal.create({
            onFetchConnectionToken: this.fetchConnectionToken(), // this line has issue
            onUnexpectedReaderDisconnect: this.unexpectedDisconnect()

async fetchConnectionToken() {
        // Your backend should call /v1/terminal/connection_tokens and return the JSON response from Stripe
        var req_data = JSON.stringify({ business_id: this.globals.new_id, location_id: "tml_EGeRNABnXI7yVq" });
        const response = await fetch(this.globals.BaseUrl + 'stripe_payment/get_connection_token', {
            method: "POST",
            body: req_data
        const data = await response.json();
        console.log('res token',
        return await;

I’m also getting response from get_connection_token but after error. Means I believe that function fetchConnectionToken is not returning value properly.

Stripe terminal docs