File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
examples/api/app/api/hello Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { headers } from "next/headers" ;
2
2
3
+ import { NextRequest } from "next/server" ;
4
+
3
5
export async function GET ( ) {
4
6
// Note: we use headers just so that the route is not built as a static one
5
7
const headersList = headers ( ) ;
6
8
const sayHi = ! ! headersList . get ( "should-say-hi" ) ;
7
9
return new Response ( sayHi ? "Hi World!" : "Hello World!" ) ;
8
10
}
9
11
10
- export async function POST ( request : Request ) {
11
- return new Response ( `Hello post-World! body=${ await request . text ( ) } ` ) ;
12
+ export async function POST ( request : NextRequest ) {
13
+ console . log ( "Before text" ) ;
14
+ const text = await request . text ( ) ;
15
+ console . log ( `text is ${ JSON . stringify ( text ) } ` ) ;
16
+ console . log ( "After text" ) ;
17
+
18
+ return new Response ( `Hello post-World! body=${ text } ` ) ;
12
19
}
You can’t perform that action at this time.
0 commit comments