Skip to content

Instantly share code, notes, and snippets.

View trungnus96's full-sized avatar
🎯
Focusing

Trung Nguyen trungnus96

🎯
Focusing
  • Brauz
  • Melbourne, Australia
View GitHub Profile
@trungnus96
trungnus96 / index.js
Created July 9, 2022 15:19 — forked from patrickbolle/index.js
Shopify JS Variant Listener
/**
* This class contains general helper methods.
*/
class Helper {
/**
* @param {String} name
* @returns {String|null}
*/
static getQueryParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]')
@trungnus96
trungnus96 / axios-catch-error.js
Created September 13, 2021 12:44 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨