File tree Expand file tree Collapse file tree 2 files changed +33
-44
lines changed Expand file tree Collapse file tree 2 files changed +33
-44
lines changed Original file line number Diff line number Diff line change 11export default defineEventHandler ( async ( event ) => {
2- try {
3- const config = useRuntimeConfig ( )
4- const body = await readBody ( event )
2+ const config = useRuntimeConfig ( )
3+ const body = await readBody ( event )
54
6- const url = `${ config . public . COMMUNITY_API_URL } /auth/`
7- const loginOptions = {
8- method : "POST" ,
9- body : body ,
10- headers : {
11- "Accept" : "*/*" ,
12- "Content-Type" : "application/json"
13- }
5+ const url = `${ config . public . COMMUNITY_API_URL } /auth/`
6+ const loginOptions = {
7+ method : "POST" ,
8+ body : body ,
9+ headers : {
10+ "Accept" : "*/*" ,
11+ "Content-Type" : "application/json"
1412 }
13+ }
1514
16- const loginResponse = await $fetch . raw ( url + 'login' , loginOptions ) ;
17-
18- const authResponse = await $fetch . raw ( url , {
19- method : 'GET' ,
20- headers : {
21- "Accept" : "*/*" ,
22- "Cookie" : loginResponse . headers . get ( 'set-cookie' )
23- }
24- } )
25- appendHeader ( event , 'Set-Cookie' , loginResponse . headers . get ( 'set-cookie' ) ) // assuming we only set one cookie
26- return authResponse . _data
15+ const loginResponse = await $fetch . raw ( url + 'login' , loginOptions ) ;
2716
28- } catch ( error ) {
29- console . log ( error ) ;
30- return false ;
31- }
17+ const authResponse = await $fetch . raw ( url , {
18+ method : 'GET' ,
19+ headers : {
20+ "Accept" : "*/*" ,
21+ "Cookie" : loginResponse . headers . get ( 'set-cookie' )
22+ }
23+ } )
24+ appendHeader ( event , 'Set-Cookie' , loginResponse . headers . get ( 'set-cookie' ) ) // assuming we only set one cookie
25+ return authResponse . _data
3226} ) ;
Original file line number Diff line number Diff line change 11export default defineEventHandler ( async ( event ) => {
2- try {
3- const query = getQuery ( event )
4- const config = useRuntimeConfig ( )
5- const sessionCookie = getCookie ( event , `${ config . public . SESSION_COOKIE_NAME } ` ) ;
2+ const query = getQuery ( event )
3+ const config = useRuntimeConfig ( )
4+ const sessionCookie = getCookie ( event , `${ config . public . SESSION_COOKIE_NAME } ` ) ;
65
7- const url = `${ config . public . COMMUNITY_API_URL } /member/${ query . id } `
8- const options = {
9- method : "GET" ,
10- headers : {
11- "Accept" : "*/*" ,
12- "Content-Type" : "application/json" ,
13- "Cookie" : `${ config . public . SESSION_COOKIE_NAME } =` + sessionCookie ,
14- }
6+ const url = `${ config . public . COMMUNITY_API_URL } /member/${ query . id } `
7+ const options = {
8+ method : "GET" ,
9+ headers : {
10+ "Accept" : "*/*" ,
11+ "Content-Type" : "application/json" ,
12+ "Cookie" : `${ config . public . SESSION_COOKIE_NAME } =` + sessionCookie ,
1513 }
16-
17- const response = await $fetch . raw ( url , options ) ;
18- return response . _data
19- } catch ( error ) {
20- console . log ( error ) ;
21- return false ;
2214 }
15+
16+ const response = await $fetch . raw ( url , options ) ;
17+ return response . _data
2318} ) ;
You can’t perform that action at this time.
0 commit comments