-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/WG-219: Adding GET hook for grabbing the username (#198)
* task/WG-219: Adding GET hook for grabbinig the username * added transform option to useGet hook to help with tranforming API responses * refactoring transform param --------- Co-authored-by: Taylor Grafft <[email protected]> Co-authored-by: Taylor Grafft <[email protected]> Co-authored-by: Taylor Grafft <[email protected]>
- Loading branch information
1 parent
9676baf
commit 2643e39
Showing
4 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { UseQueryResult } from 'react-query'; | ||
import { ApiService, AuthenticatedUser } from '../../types'; | ||
import { useGet } from '../../requests'; | ||
|
||
const useAuthenticatedUser = (): UseQueryResult<AuthenticatedUser> => { | ||
return useGet<AuthenticatedUser>({ | ||
endpoint: '/oauth2/userinfo?schema=openid', | ||
key: ['username'], | ||
apiService: ApiService.Tapis, | ||
transform: (data) => ({ | ||
username: data.name, | ||
email: data.email, | ||
}), | ||
}); | ||
}; | ||
|
||
export default useAuthenticatedUser; |
This file contains 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
This file contains 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
This file contains 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