Skip to content

Commit

Permalink
add route
Browse files Browse the repository at this point in the history
  • Loading branch information
sayandedotcom committed Sep 14, 2024
1 parent 5bfc0e4 commit ab72b97
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
5 changes: 2 additions & 3 deletions apps/web/app/[locale]/client/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"use client";

import { useQuery } from "@tanstack/react-query";

import { requests } from "@/lib/axios";
import axios from "axios";

function Client() {
const { data, error, isLoading } = useQuery({
queryKey: ["test"],
queryFn: () => {
return requests.get("/test", {
return axios.get("/api/v1/test", {
headers: {
name: "Sayan De from Client Component",
},
Expand Down
61 changes: 31 additions & 30 deletions apps/web/app/[locale]/server/page.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
import axios from "axios";

async function Server() {
// const queryClient = new QueryClient();
// await queryClient.prefetchQuery({
// queryKey: ["test"],
// queryFn: () => {
// return axios.get("http://localhost:3000/api/v1/test", {
// headers: {
// name: "Sayan De from Client Component",
// },
// });
// },
// });
// const { data, error, isLoading } = useQuery({
// queryKey: ["test"],
// queryFn: () => {
// return axios.get("http://localhost:3000/api/v1/test", {
// headers: {
// name: "Sayan De from Client Component",
// },
// });
const response = await fetch("http://localhost:3000/api/v1/test", {
method: "GET",
}).then((ans) => ans.json());
// .get("/api/v1/test", {
// headers: {
// name: "Sayan De from Server Component",
// },
// });
// console.log("😊datadatadatadatadata",data);
const response = await axios
.get("http://localhost:3000/api/v1/test", {
headers: {
name: "Sayan De from Server Component",
},
})
.then((ans) => ans.data);
// })
// .then((ans) => ans.data);

console.log("😊datadatadatadatadata", response);
return <div>{response?.Hi}</div>;
}

export default Server;

// const queryClient = new QueryClient();
// await queryClient.prefetchQuery({
// queryKey: ["test"],
// queryFn: () => {
// return axios.get("http://localhost:3000/api/v1/test", {
// headers: {
// name: "Sayan De from Client Component",
// },
// });
// },
// });
// const { data, error, isLoading } = useQuery({
// queryKey: ["test"],
// queryFn: () => {
// return axios.get("http://localhost:3000/api/v1/test", {
// headers: {
// name: "Sayan De from Client Component",
// },
// });
// },
// });
// console.log("😊datadatadatadatadata",data);

0 comments on commit ab72b97

Please sign in to comment.