Improvements to Webflow-Node

This commit is contained in:
ricardo 2020-06-15 20:31:18 -04:00
parent 0c144e4b0f
commit 346ae8efc9
2 changed files with 13 additions and 4 deletions

View file

@ -28,7 +28,7 @@ export class WebflowOAuth2Api implements ICredentialType {
{
displayName: 'Scope',
name: 'scope',
type: 'string' as NodePropertyTypes,
type: 'hidden' as NodePropertyTypes,
default: '',
},
{

View file

@ -1,4 +1,7 @@
import { OptionsWithUri } from 'request';
import {
OptionsWithUri,
} from 'request';
import {
IExecuteFunctions,
IExecuteSingleFunctions,
@ -6,7 +9,10 @@ import {
ILoadOptionsFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IDataObject } from 'n8n-workflow';
import {
IDataObject,
} from 'n8n-workflow';
export async function webflowApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const authenticationMethod = this.getNodeParameter('authentication', 0);
@ -40,6 +46,9 @@ export async function webflowApiRequest(this: IHookFunctions | IExecuteFunctions
return await this.helpers.requestOAuth2!.call(this, 'webflowOAuth2Api', options);
}
} catch (error) {
throw new Error('Webflow Error: ' + error.code + error.msg);
if (error.response.body.err) {
throw new Error(`Webflow Error: [${error.statusCode}]: ${error.response.body.err}`);
}
return error;
}
}