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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SeamHttpRequest #67

Merged
merged 33 commits into from
Mar 27, 2024
Merged

Add SeamHttpRequest #67

merged 33 commits into from
Mar 27, 2024

Conversation

phpnode
Copy link
Contributor

@phpnode phpnode commented Mar 25, 2024

It's often useful to be able to inspect an API Request before it is sent. This PR adds a new class, SeamHttpRequest which implements PromiseLike<T> which holds some information about the request before it is sent to the server. The actual request to the server is made when the SeamHttpRequest is awaited.

e.g.

const request = client.devices.list();
console.log(request.url);
console.log(request.method);
console.log(request.body);
const devices = await request;

Of course the request can be awaited immediately, as normal:

const devices = await client.devices.list();

I'm not married to the naming here so please feel free to bikeshed it 😄

@phpnode phpnode requested a review from razor-x as a code owner March 25, 2024 12:09
@razor-x
Copy link
Contributor

razor-x commented Mar 25, 2024

SeamApiRequest or SeamHttpRequest to match SeamHttp?

@phpnode phpnode changed the title Add SeamApiRequest Add SeamHttpRequest Mar 26, 2024
@razor-x
Copy link
Contributor

razor-x commented Mar 26, 2024

I meant to mention this earlier, but we should add a section to https://github.com/seamapi/javascript-http?tab=readme-ov-file#advanced-usage Name could be "Inspecting the Request"

src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Co-authored-by: Evan Sosenko <[email protected]>
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
src/lib/seam/connect/seam-http-request.ts Outdated Show resolved Hide resolved
@phpnode phpnode merged commit 3e0dda8 into main Mar 27, 2024
15 checks passed
@phpnode phpnode deleted the seam-api-request branch March 27, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants