🚧 (wip) forward callback to backend
This commit is contained in:
16
features/oauth-callback/lib/sendCallbackToServer.ts
Normal file
16
features/oauth-callback/lib/sendCallbackToServer.ts
Normal file
@ -0,0 +1,16 @@
|
||||
"use server";
|
||||
import { api } from "@/shared/api/connector";
|
||||
|
||||
export const SendCallbackToServer = async (data: Record<string, any>) => {
|
||||
try {
|
||||
const response = await api.get("auth/google/callback", {
|
||||
searchParams: { ...data },
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
console.log(result);
|
||||
} catch (error) {
|
||||
console.error("Error sending callback to server:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@ -1,10 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { CircularProgress } from "@heroui/react";
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { ParamProps } from "../types/ParamProps";
|
||||
import { SendCallbackToServer } from "../lib/sendCallbackToServer";
|
||||
|
||||
const LoadingProcess = ({ callbackData }: { callbackData: ParamProps }) => {
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const response = await SendCallbackToServer(callbackData);
|
||||
console.log(
|
||||
`Callback data sent to server successfully: ${JSON.stringify(
|
||||
response
|
||||
)}`
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error during loading process:", error);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
return (
|
||||
<div className="w-full flex flex-col items-center text-center mt-[26vh]">
|
||||
<CircularProgress aria-label="Loading..." size="lg" />
|
||||
|
||||
Reference in New Issue
Block a user