🐛 Fix error when checking if webhook exists (#1129)

* 🐛 Fix error when checking if webhook exists

* zap: Small fix
This commit is contained in:
Ricardo Espinoza
2020-11-07 13:44:13 -05:00
committed by GitHub
parent a6cf9bceb3
commit 96cffdfd1e
2 changed files with 79 additions and 87 deletions

View File

@@ -24,7 +24,7 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
throw new Error('No credentials got returned!');
}
const headerWithAuthentication = Object.assign({},
{ Authorization: ` Basic ${Buffer.from(`${credentials.apiKey}:${credentials.password}`).toString(BINARY_ENCODING)}` });
{ Authorization: `Basic ${Buffer.from(`${credentials.apiKey}:${credentials.password}`).toString(BINARY_ENCODING)}` });
const options: OptionsWithUri = {
headers: headerWithAuthentication,
@@ -47,6 +47,7 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions
try {
return await this.helpers.request!(options);
} catch (error) {
console.log(error.response.body);
if (error.response.body && error.response.body.errors) {
let message = '';
if (typeof error.response.body.errors === 'object') {