mirror of
https://github.com/D4M13N-D3V/comissions-app-ui.git
synced 2025-03-13 15:55:08 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import { withApiAuthRequired } from "@auth0/nextjs-auth0";
|
|
import { getAccessToken } from '@auth0/nextjs-auth0';
|
|
|
|
|
|
export default withApiAuthRequired(async function handler(req, res) {
|
|
if(req.method !== 'GET') {
|
|
////console.log(req.body)
|
|
const { accessToken } = await getAccessToken(req, res);
|
|
const response = await fetch(process.env.NEXT_PUBLIC_API_URL+'/api/User', {
|
|
headers: {
|
|
"Authorization": `Bearer ${accessToken}`,
|
|
"Content-Type": "application/json"
|
|
},
|
|
method: "PUT",
|
|
body: req.body
|
|
});
|
|
|
|
let result = await response.json();
|
|
res.status(200).json(result);
|
|
}
|
|
else{
|
|
const { accessToken } = await getAccessToken(req, res);
|
|
const response = await fetch(process.env.NEXT_PUBLIC_API_URL+'/api/User', {
|
|
headers: {
|
|
"Authorization": `Bearer ${accessToken}`,
|
|
"Content-Type": "application/json"
|
|
}
|
|
});
|
|
|
|
let result = await response.json();
|
|
res.status(200).json(result);
|
|
}
|
|
}); |