-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
62 lines (57 loc) · 1.42 KB
/
page.tsx
File metadata and controls
62 lines (57 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use client'
import { createApi } from '@devup-api/fetch'
import { Box, Text } from '@devup-ui/react'
import { useEffect } from 'react'
const api = createApi('https://api.example.com')
const api2 = createApi('https://api.example2.com', undefined, 'openapi2.json')
export default function Home() {
useEffect(() => {
api2.get('getUsers2', {}).then((res) => {
console.log(res)
})
api.get('getUsers', {}).then((res) => {
console.log(res)
})
api
.get('getUserById', {
params: { id: 1 },
})
.then((res) => {
console.log(res)
})
api
.post('createUser', {
body: {
name: 'John Doe',
email: 'foo@bar.com',
},
})
.then((res) => {
console.log(res)
})
}, [])
return (
<Box>
<Text>Next.js Example (Turbopack)</Text>
<Box>
<Box>
<Box>
<Box>
{(() => {
try {
const urlMap = process.env.DEVUP_API_URL_MAP
if (!urlMap) return 'Not available'
const parsed =
typeof urlMap === 'string' ? JSON.parse(urlMap) : urlMap
return JSON.stringify(parsed, null, 2)
} catch {
return 'Error parsing URL map'
}
})()}
</Box>
</Box>
</Box>
</Box>
</Box>
)
}