Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keepAlive sample #1561

Merged
merged 2 commits into from
Jun 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions samples/keepalive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017, Google, Inc.
// Copyright 2023 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand Down Expand Up @@ -41,17 +41,11 @@ async function main() {
const agent = new https.Agent({keepAlive: true});

// use the agent as an Axios config param to make the request
const res = await client.request({
url,
httpsAgent: agent,
});
const res = await client.request({url, agent});
console.log(res.data);

// Re-use the same agent to make the next request over the same connection
const res2 = await client.request({
url,
httpsAgent: agent,
});
const res2 = await client.request({url, agent});
console.log(res2.data);
}

Expand Down