TypeError: t.split is not a function

I am currently working on converting our EASDK integration to App-Bridge and I am hitting road-block after road-block.

This basis example is throwing a javascript error


This results in

[email removed] Uncaught (in promise) TypeError: t.split is not a function
at [email removed]
(anonymous) [email removed] [email removed]
Promise.then (async)
getState [email removed] [email removed]
(anonymous) [email removed] {my endpoint}

This is extremely frustrating.. can anyone suggest what can be done.. this is a basic browser example.. brutal.

Note the exact same error occurs when using app-bridge@2

Testing in Chrome browser, the most recent version.

Switched to dev version

The error is now

Uncaught (in promise) TypeError: query.split is not a function
at index.development.js:2943
(anonymous) [email removed] index.development.js:2943
Promise.then (async)
getState [email removed] index.development.js:2941
(anonymous) [email removed] {my endpoint}

@Shopify_77 the code here doesn’t make sense..

getState: function (query) {
                return new Promise(function (resolve) {
                    getStateListeners.push(resolve);
                    dispatcher(types_1.MessageType.GetState);
                }).then(function (state) {
                    if (query) {
                        return query.split('.').reduce(function (value, key) {
                            if (typeof state !== 'object' || Array.isArray(state)) {
                                return undefined;
                            }
                            value = state[key];
                            state = value;
                            return value;
                        }, undefined);
                    }
                    return state;
                });
            },

the getState method takes a query argument - which is a function according to the docs - https://shopify.dev/apps/tools/app-bridge/methods#app-object-methods

So why then are you calling

return query.split('.').

on something that is supposed to be a function??

Looks like the call to getState is incorrect and should be

app.getState().then(function(data) {
      console.log(data);
  });

Works in the Admin now, but doesn’t work on POS.. which is

app.getState('pos').then(function(data) {
      console.log(data);
  });