-
Notifications
You must be signed in to change notification settings - Fork 23
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
chore(website): type getPackage using the API types #1307
Conversation
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 0184f3c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
5633f24
to
74429b5
Compare
const response = await axios.get<{ total: any; data: ApiDocument[] }>(`packages/${name}`, { | ||
baseURL: externalLinks.API_CANNON, | ||
}); | ||
return response.data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be response.data.data
?
Not sure about the response
object, but the API on GET /packages/:packageName
responds with:
{
status: number,
total: number,
data: { ... }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, on line 21 we are defining the shape of the date.
then on line 24, we return response.data
which will be {total: any; data: ApiDocument}
. If we return response.data.data
we will be removing the total
prop which might be useful in the future.
I just realized that total
should be of type number, not any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah perfect, just wanted to make sure that it is being used correctly on the Components
This PR adds types to the getPackage method that brings packages by name or full ref.
All the logic was moved to two new hooks.