Skip to content

Instantly share code, notes, and snippets.

@panoply
Created August 5, 2019 10:37
Show Gist options
  • Save panoply/17749993bd27b54acad42cce6cfab976 to your computer and use it in GitHub Desktop.
Save panoply/17749993bd27b54acad42cce6cfab976 to your computer and use it in GitHub Desktop.
/*
PARSE SHOPIFY SECTION
*/
const regex = /(?<=application\/json">\n?)({|\[)([\s\S]+?)(?=<\/)/g
m.request({
url: '/?section_id=1564432230347',
extract: function (xhr) {
return {
status: xhr.status,
body: xhr.responseText
}
}
})
.then(function (response) {
const match = response.body.match(regex)
console.log(JSON.parse(match[0]))
}).catch(e => console.log(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment