Answer the question
In order to leave comments, you need to log in
How to get data from fetch in another file?
How can I get data from fetch in another file?
Need to get response in Form.tsx file for onSubmit
from-api.ts
await fetch('https://jsonplaceholder.typicode.com/todos')
.then((response) => {
return response.json()
})
.then((data) => {
console.log(data)
})
const onSubmit: SubmitHandler<IFormInputs> = async (data) => {
const { res } = await FormApi.sendForm(data)
console.log(res)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question