title: Shopify get Customer Metafields
body: <p>UPDATE: I have this Private API request to get a customer metafield data that sends a request to the shopify admin.</p>
  
  <pre><code>const {getAccessToken} = require('./auth')
      const request = require('request')
      const {shopFromPermanentDomain} = require('./helpers')
  
  const getCustomerMetafields = ({accessToken, id, shop}) =&gt; new Promise((resolve, reject) =&gt; {
    request({
      url:`https://${shop}.myshopify.com/admin/customers/${id}/metafields.json',
      headers: {
        'X-Shopify-Access-Token': accessToken
      }
    }, (error, response, body) =&gt; {
      const {errors} = JSON.parse(body)
  
      if (response.statusCode === 200) {
        const { metafields } = JSON.parse(body)
        resolve(metafields)
      }
  
      reject({error: errors, status: 500})
    })
  })
  
  const getCustomerMetafieldsResponse = (req, res) =&gt; {
    const {id, permanentDomain} = req.body
  
    if (id &amp;&amp; permanentDomain) {
      const shop = shopFromPermanentDomain(permanentDomain)
  
      getAccessToken({shop})
        .then(accessToken =&gt; getCustomerMetafields({accessToken, id, shop})
          .then(meta =&gt; res.json({
            meta,
            status: 200
          }))
        )
        .catch(({error, status}) =&gt; res.json({error, status}))
    } else {
      res.json({error: 'Missing params', status: 500})
    }
  }
  
  module.exports = getCustomerMetafieldsResponse
  </code></pre>
  
  <p>I make this request from the front-end to my API with the following request. </p>
  
  <pre><code>const getCustomerMeta = ({
     id,
     permanentDomain
  }) =&gt; new Promise((resolve, reject) =&gt; {
    post({
      params: { email, permanentDomain, task: 'get-customer-meta' },
      then: ({ error, id, state, status }) =&gt; {
        if (status === 200) {
          resolve({ id, state })
        }
  
        reject(error)
      },
      url: '/apps/spoke'
    })
  })
      getCustomerMeta({
         id, // 98303739294 (Customer ID)
         permanentDomain // "store.myshopify.com"
      })
  </code></pre>
  
  <p>When making this request, I get the following request error:</p>
  
  <pre><code> 500 (Internal Server Error)
  
  VM706781:8 Uncaught SyntaxError: Unexpected token &lt; in JSON at position 7
      at JSON.parse (&lt;anonymous&gt;)
      at XMLHttpRequest.l.onload
  </code></pre>
  
  <p>I then want to GET the customer metafields data so that I can populate the front-end with the data gathered.</p>
  
  <p>Thanks!</p>