started multithreading

This commit is contained in:
YasinOnm08 2024-09-19 13:02:56 +02:00
parent ef2e40ca4a
commit 024ceeda4e
5 changed files with 103 additions and 2 deletions

View file

@ -0,0 +1,49 @@
"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