Get Magento 2 customer ID in Vue front-end

215 Views Asked by At

I am working on Vue Storefront ( a Nuxt.js with Express.js based framework) where GraphQL queries are used to get data from Magento 2.

I tried to add customers ID in the GraphQL query for customer data but it returned as Null (see response below). I've read this is not recommended but I still want to try something in my client with the Customer ID.

   "data":{
      "customer":{
         "__typename":"Customer",
         "date_of_birth":null,
         "email":"[email protected]",
         "firstname":"john",
         "is_subscribed":false,
         "id":null,
         "addresses":[
            ...

How can I, safety risks aside, still aquire the Customer ID in my front-end? Is there a small GraphQl query I can execute as a javascript function? I also have an Express.js part of my app where I can securely request and send data to other platforms (this is server side).

0

There are 0 best solutions below