File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from "react" ;
2- import axios from "axios" ;
3- import dynamic from "next/dynamic" ;
42
5- // harperDb fetch call
6- import { harperFetch } from "../../utils/HarperFetch " ;
3+ // axios
4+ import axios from "axios " ;
75
8- // Dummy Shape Data
9- // import { shapes } from "../../data/shapes ";
6+ // dynamic from next
7+ import dynamic from "next/dynamic " ;
108
119// loader
1210import Loader from "react-loader-spinner" ;
@@ -52,12 +50,12 @@ const App = (props) => {
5250 shapes = response . data ;
5351
5452 // Fetch the shapes liked by the logged-in user
55- const likedShapes = await harperFetch ( {
56- operation : "sql" ,
57- sql : `SELECT *
58- FROM tryshape.likes
59- WHERE email = '${ user . email } '` ,
53+ const likedResponse = await axios . get ( "/api/GET/likes" , {
54+ params : {
55+ email : user . email
56+ }
6057 } ) ;
58+ const likedShapes = likedResponse . data ;
6159
6260 // If there are liked shapes, take out the shape_id
6361 if ( likedShapes . length > 0 ) {
Original file line number Diff line number Diff line change 1+ export default async function handler ( req , res ) {
2+ const { email } = req . query ;
3+
4+ let sql = `SELECT *
5+ FROM tryshape.likes
6+ WHERE email = '${ email } '` ;
7+
8+
9+ const request = await fetch ( process . env . NEXT_PUBLIC_DB_URL , {
10+ method : "POST" ,
11+ headers : {
12+ "Content-Type" : "application/json" ,
13+ Authorization : `Basic ${ process . env . NEXT_PUBLIC_DB_AUTHORIZATION } ` ,
14+ } ,
15+ body : JSON . stringify ( {
16+ operation : "sql" ,
17+ sql : sql ,
18+ } ) ,
19+ } ) ;
20+
21+ const data = await request . json ( ) ;
22+ // console.log(data);
23+
24+ res . status ( 200 ) . json ( data ) ;
25+ }
You can’t perform that action at this time.
0 commit comments