Commit 206d2e9c authored by tom's avatar tom

make request on page load

parent d6294509
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'
type Data = {
name: string;
}
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>,
) {
res.status(200).json({ name: 'John Doe' })
}
...@@ -2,8 +2,17 @@ import React from 'react'; ...@@ -2,8 +2,17 @@ import React from 'react';
import type { NextPage } from 'next'; import type { NextPage } from 'next';
import Head from 'next/head' import Head from 'next/head'
import fetch from 'api/utils/fetch';
import PrivateTags from 'ui/pages/PrivateTags'; import PrivateTags from 'ui/pages/PrivateTags';
export async function getServerSideProps() {
const response = await fetch('/account/v1/user/tags/address')
const data = await response.json()
return { props: { data } }
}
const PrivateTagsPage: NextPage = () => { const PrivateTagsPage: NextPage = () => {
return ( return (
<> <>
......
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
TabList, TabList,
TabPanel, TabPanel,
TabPanels, TabPanels,
Button,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import Page from 'ui/shared/Page/Page'; import Page from 'ui/shared/Page/Page';
...@@ -16,16 +15,10 @@ import PrivateAddressTags from 'ui/privateTags/PrivateAddressTags'; ...@@ -16,16 +15,10 @@ import PrivateAddressTags from 'ui/privateTags/PrivateAddressTags';
import PrivateTransactionTags from 'ui/privateTags/PrivateTransactionTags'; import PrivateTransactionTags from 'ui/privateTags/PrivateTransactionTags';
const PrivateTags: React.FC = () => { const PrivateTags: React.FC = () => {
const handleClick = React.useCallback(async() => {
await fetch('/api/account/private-tags/address');
}, [])
return ( return (
<Page> <Page>
<Box h="100%"> <Box h="100%">
<Heading as="h1" size="lg" marginBottom={ 8 }>Private tags</Heading> <Heading as="h1" size="lg" marginBottom={ 8 }>Private tags</Heading>
<Button onClick={ handleClick }>click</Button>
<Tabs variant="soft-rounded" colorScheme="blue" isLazy> <Tabs variant="soft-rounded" colorScheme="blue" isLazy>
<TabList marginBottom={ 8 }> <TabList marginBottom={ 8 }>
<Tab>Address</Tab> <Tab>Address</Tab>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment