Skip to content

Commit

Permalink
fix(beeminder Node): fix request id not being sent when creating a ne…
Browse files Browse the repository at this point in the history
…w datapoint
  • Loading branch information
Joffcom authored Sep 2, 2022
1 parent 071ab40 commit 73c5210
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
23 changes: 22 additions & 1 deletion packages/nodes-base/credentials/BeeminderApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ICredentialType, INodeProperties } from 'n8n-workflow';
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';

export class BeeminderApi implements ICredentialType {
name = 'beeminderApi';
Expand All @@ -18,4 +23,20 @@ export class BeeminderApi implements ICredentialType {
default: '',
},
];

authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
body: {
auth_token: '={{$credentials.authToken}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://www.beeminder.com/api/v1',
url: `=/users/{{$credentials.user}}.json`,
},
};
}
3 changes: 1 addition & 2 deletions packages/nodes-base/nodes/Beeminder/Beeminder.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
INodePropertyOptions,
INodeType,
INodeTypeDescription,
NodeOperationError,
} from 'n8n-workflow';

import {
Expand Down Expand Up @@ -197,7 +196,7 @@ export class Beeminder implements INodeType {
},
{
displayName: 'Request ID',
name: 'requestId',
name: 'requestid',
type: 'string',
default: '',
placeholder: '',
Expand Down
6 changes: 1 addition & 5 deletions packages/nodes-base/nodes/Beeminder/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export async function beeminderApiRequest(
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = (await this.getCredentials('beeminderApi')) as IDataObject;

Object.assign(body, { auth_token: credentials.authToken });

const options: OptionsWithUri = {
method,
body,
Expand All @@ -36,7 +32,7 @@ export async function beeminderApiRequest(
}

try {
return await this.helpers.request!(options);
return await this.helpers.requestWithAuthentication.call(this, 'beeminderApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
Expand Down

0 comments on commit 73c5210

Please sign in to comment.