feat: add NitroFetchRequest type and enhance $fetch's request type#209
Merged
pi0 merged 3 commits intonitrojs:mainfrom May 10, 2022
Merged
feat: add NitroFetchRequest type and enhance $fetch's request type#209pi0 merged 3 commits intonitrojs:mainfrom
NitroFetchRequest type and enhance $fetch's request type#209pi0 merged 3 commits intonitrojs:mainfrom
Conversation
Enhance the $fetch request's type by inferring server route's string literal (InternalApi interface). supporting auto-complete and showing type hints.
2 tasks
danielroe
reviewed
May 10, 2022
Co-authored-by: Daniel Roe <daniel@roe.dev>
pi0
reviewed
May 10, 2022
pi0
approved these changes
May 10, 2022
Member
|
Thanks @didavid61202 @danielroe 💚 |
This was referenced May 11, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance the $fetch request's type by inferring the server route's string literal (InternalApi interface). supporting auto-complete and showing type hints.
🔗 Linked issue
resolves nuxt/framework#208
❓ Type of change
📚 Description
Add a new type
NitroFetchRequestto Enhance$fetch's request type by inferring the generated server route's string literal (InternalApi interface).This will provide better DX and prevent typos while $fetch by supporting auto-complete and showing type hints when entering the request. And should still be able to pass other valid request URLs like https://example.com/api or Request object like new Request('/api/test')
This will also provide Nuxt 3's
useFetchanduseLazyFetchto also have type hints on request parameters with little type changes. see issue nuxt/nuxt#13934 and PR nuxt/framework#4825Usage scenario
📝 Checklist