"use client"
import React, { useEffect, useState } from "react";
import axios from 'axios';

type lol = {
    message: string[]
}
const InputOutputBackend: React.FC = () => {
    const [getMessage, setGetMessage] = useState("")
    const [accessToken, setAccessToken] = useState("")
    const [postMessage, setPostMessage] = useState("")
    const [input, setInput] = useState("")

    useEffect(() => {
        const worker = new Worker(new URL("./ProcessAPI.js", import.meta.url))
        worker.postMessage({})
        worker.onmessage = (e) => {
            setAccessToken(e.data.access_token)
            console.log(accessToken)
        }

        return () => {
            worker.terminate()
        }
    })
    
    const HandleGetRequest = () => {
        axios.get('/interstellar/api/ai_get')
            .then(Response => {
                setAccessToken(Response.data.response)
            }).catch(error => {
            console.error("Error with GET response request:", error)
        })
    }

    const HandlePostRequest = () => {
        axios.post('/interstellar/api/ai_send', {})
    }
    
    return <div>Hello {accessToken}</div>
}

export default InputOutputBackend





 