简体   繁体   中英

How can I get current store details in shopify app front-end using node and express

I am developing shopify public app with node.js and express and want to know that how can get the current store details at my app front-end when store admin open my app

I am getting store details at back-end side in query_string when store admin click on navigation link of my app but not able to get at front-end side with jquery or javascripts and I am using express and ejs view templating for front-end

can any one please help me out this that how to manage current store details at front-end side. Thank you

I got the solution to access store details at my shopify app front-end as following

require changes => use ' cookie ' npm package for storing data in cookies and also set cookie as like this in your controller

   const cookie = require('cookie');

  app.get('/',(req,res)=>{
    const data=req.query;
    res.cookie('shop_detail',data);
});

get cookie from your front-end use following javascript function

      function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
          var c = ca[i];
          while (c.charAt(0)==' ') c = c.substring(1,c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
          }
          return null;
      }

call this function like this

readCookie('shop_detail');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM