Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
29c7b39e
Commit
29c7b39e
authored
Sep 22, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call api from client for user profile data
parent
82984260
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
getCspPolicy.ts
lib/csp/getCspPolicy.ts
+1
-0
useFetch.tsx
lib/hooks/useFetch.tsx
+1
-0
useFetchProfileInfo.tsx
lib/hooks/useFetchProfileInfo.tsx
+6
-1
No files found.
lib/csp/getCspPolicy.ts
View file @
29c7b39e
...
...
@@ -37,6 +37,7 @@ function makePolicyMap() {
'
connect-src
'
:
[
KEY_WORDS
.
SELF
,
...
MAIN_DOMAINS
,
// webpack hmr in safari doesn't recognize localhost as 'self' for some reason
isDev
?
'
ws://localhost:3000/_next/webpack-hmr
'
:
''
,
...
...
lib/hooks/useFetch.tsx
View file @
29c7b39e
...
...
@@ -13,6 +13,7 @@ export interface ErrorType<T> {
interface
Params
{
method
?:
RequestInit
[
'
method
'
];
body
?:
Record
<
string
,
unknown
>
;
credentials
?:
RequestCredentials
;
}
export
default
function
useFetch
()
{
...
...
lib/hooks/useFetchProfileInfo.tsx
View file @
29c7b39e
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
...
...
@@ -13,10 +14,14 @@ interface Error {
export
default
function
useFetchProfileInfo
()
{
const
fetch
=
useFetch
();
const
router
=
useRouter
();
const
url
=
new
URL
(
`/
${
router
.
query
.
network_type
}
/
${
router
.
query
.
network_sub_type
}
/api/account/v1/user/info`
,
'
https://blockscout.com
'
);
return
useQuery
<
unknown
,
Error
,
UserInfo
>
([
'
profile
'
],
async
()
=>
{
return
fetch
(
'
/api/account/profile
'
);
return
fetch
(
url
.
toString
(),
{
credentials
:
'
include
'
}
);
},
{
refetchOnMount
:
false
,
enabled
:
Boolean
(
router
.
query
.
network_type
&&
router
.
query
.
network_sub_type
),
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment