Questions and discussions about using the Shopify CLI and Shopify-built libraries.
Hello,
I am using Ruby on rails with shopify_app gem. I have initialized everything as mentioned in Readme. The embedded app is working as expected. I am trying to open the Shopify app on a standalone page and not inside Shopify admin.
Things I have tried:
1. By setting `config.embedded_app = false` in shopify_app.rb.
2. I have also disabled the "Embed your app" setting in app dashboard. (Extensions -> Embedded App)
After the above steps, the app is successfully redirecting to out of Shopify admin page but nothing shows up
In the console, it is throwing an error on line 2 of `shopify_app.js`
Error:
Uncaught TypeError: Cannot read property 'dataset' of null
at HTMLDocument.<anonymous> (shopify_app.js:2)
shopify_app.js :
document.addEventListener('DOMContentLoaded', () => {
var data = document.getElementById('shopify-app-init').dataset
var AppBridge = window['app-bridge']
var createApp = AppBridge.default
window.app = createApp({
apiKey: data.apiKey,
shopOrigin: data.shopOrigin,
})
var actions = AppBridge.actions
var TitleBar = actions.TitleBar
TitleBar.create(app, {
title: data.page,
})
})
I am confused currently about how to move forward. would really appreciate your help. Many thanks in advance.
hey @sidepanda were you able to solve this issue? I'm having the same problem. I created a fresh project and still it throws this error.
I fixed it with this way:
You can using layout is embedded_app in controller example:
class ProductsController < AuthenticatedController
layout 'embedded_app'
def index
@Anonymous = ShopifyAPI::Product.all(limit: 10)
end
end
@sidepanda wrote:Hello,
I am using Ruby on rails with shopify_app gem. I have initialized everything as mentioned in Readme. The embedded app is working as expected. I am trying to open the Shopify app on a standalone page and not inside Shopify admin.
Things I have tried:
1. By setting `config.embedded_app = false` in shopify_app.rb.
2. I have also disabled the "Embed your app" setting in app dashboard. (Extensions -> Embedded App)
After the above steps, the app is successfully redirecting to out of Shopify admin page but nothing shows up
In the console, it is throwing an error on line 2 of `shopify_app.js`
Error:
Uncaught TypeError: Cannot read property 'dataset' of null
at HTMLDocument.<anonymous> (shopify_app.js:2)shopify_app.js :
document.addEventListener('DOMContentLoaded', () => {
var data = document.getElementById('shopify-app-init').dataset
var AppBridge = window['app-bridge']
var createApp = AppBridge.default
window.app = createApp({
apiKey: data.apiKey,
shopOrigin: data.shopOrigin,
})
var actions = AppBridge.actions
var TitleBar = actions.TitleBar
TitleBar.create(app, {
title: data.page,
})
})
I am confused currently about how to move forward. would really appreciate your help. Many thanks in advance.