I am trying to get
const [data, setData] = React.useState('');
const [pointdata, setPointData] = React.useState('');
in my API directory. however, everytime I try and run the code I get Cannot read properties of null (reading 'useState'
However, the same code there works fine when it is in a /page/myfile.js
How can I put useState and useEffect in an API directory or is their another way to do this?
Why is it an API file because we are posting form data to this.
import React, { useState } from "react";
export default async function gll(req, res) {
const [data, setData] = React.useState('');
const [pointdata, setPointData] = React.useState('');
}