Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/run_action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import exponentialBackoffWithJitter from './exponential_backoff_with_jitter';
import objectToQueryParamString from './object_to_query_param_string';
import packageVersion from './package_version';
import fetch from './fetch';
import AbortController from './abort-controller';
import Base from './base';
Expand All @@ -14,8 +13,6 @@ type ActionParams = {[key: string]: ActionBody};
type ActionResponse = {-readonly [key in keyof Response]: Response[key]} & {statusCode: number};
type ActionCallback = (error: ActionError, response?: ActionResponse, body?: ActionBody) => void;

const userAgent = `Airtable.js/${packageVersion}`;

function runAction(
base: Base,
method: string,
Expand All @@ -29,20 +26,12 @@ function runAction(
base._id
}${path}?${objectToQueryParamString(queryParams)}`;

const headers = {
authorization: `Bearer ${base._airtable._apiKey}`,
// Use the same header construction as makeRequest so customHeaders work
const headers = base._getRequestHeaders({
'x-api-version': base._airtable._apiVersion,
'x-airtable-application-id': base.getId(),
'content-type': 'application/json',
};
const isBrowser = typeof window !== 'undefined';
// Some browsers do not allow overriding the user agent.
// https://github.com/Airtable/airtable.js/issues/52
if (isBrowser) {
headers['x-airtable-user-agent'] = userAgent;
} else {
headers['User-Agent'] = userAgent;
}
...base._airtable._customHeaders,
});

const controller = new AbortController();
const normalizedMethod = method.toUpperCase();
Expand Down