matt HOFFNER commited on
Commit
f16de12
β€’
1 Parent(s): 5f5314e
Files changed (2) hide show
  1. app/page.tsx +1 -1
  2. pages/api/functions/index.ts +4 -3
app/page.tsx CHANGED
@@ -22,7 +22,7 @@ const Page: React.FC = () => {
22
  "Content-Type": "application/json",
23
  },
24
  body: JSON.stringify({
25
- prompt: args,
26
  name: name
27
  })
28
  } as any);
 
22
  "Content-Type": "application/json",
23
  },
24
  body: JSON.stringify({
25
+ args: args,
26
  name: name
27
  })
28
  } as any);
pages/api/functions/index.ts CHANGED
@@ -105,15 +105,16 @@ const serpEmbedApi = async ({ input }: any) => {
105
  }
106
 
107
  export default async function handler(req: NextApiRequest, res: NextApiResponse) {
108
- const prompt = req.body.prompt as string;
109
  const functionName = req.body.name as string;
 
110
 
111
  try {
112
  if (functionName === 'searchApi') {
113
- const result = await serpEmbedApi(JSON.parse(prompt));
114
  return res.status(200).send(result);
115
  } else {
116
- const result = await surferEmbedApi(prompt)
117
  return res.status(200).send(result);
118
  }
119
  } catch (error) {
 
105
  }
106
 
107
  export default async function handler(req: NextApiRequest, res: NextApiResponse) {
108
+ const args = req.body.args as string;
109
  const functionName = req.body.name as string;
110
+ const functionInput = JSON.parse(args);
111
 
112
  try {
113
  if (functionName === 'searchApi') {
114
+ const result = await serpEmbedApi(functionInput);
115
  return res.status(200).send(result);
116
  } else {
117
+ const result = await surferEmbedApi(functionInput)
118
  return res.status(200).send(result);
119
  }
120
  } catch (error) {