Skip to content

Commit

Permalink
fix: use get instead of post (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Feb 10, 2023
1 parent 9e094b1 commit 62074c0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/node/src/remote/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,19 @@ export class RemoteEvaluationClient {
): Promise<Variants> {
const userContext = this.addContext(user || {});
const endpoint = `${this.config.serverUrl}/sdk/vardata`;
const encodedUser = Buffer.from(JSON.stringify(userContext)).toString(
'base64',
);
const headers = {
Authorization: `Api-Key ${this.apiKey}`,
'X-Amp-Exp-User': encodedUser,
};
const body = JSON.stringify(userContext);
// CDN can only cache requests where the body is < 8KB
if (body.length > 8000) {
console.warn(
`[Experiment] encoded user object length ${body.length} cannot be cached by CDN; must be < 8KB`,
);
}
this.debug('[Experiment] Fetch variants for user: ', userContext);
const response = await this.httpClient.request(
endpoint,
'POST',
'GET',
headers,
body,
null,
timeoutMillis,
);
if (response.status !== 200) {
Expand Down

0 comments on commit 62074c0

Please sign in to comment.