My code is as follows:
//fetch tasks from server
const fetchTasks=()=>{
const fTask = async ()=>{
const res = await fetch('http://localhost:5000/tasks')
const data = await res.json()
console.log("data", data)
}
fTask()
}
fetchTasks()
I was expecting the data to be logged into the console only once, but for some reason, it is being logged twice. I tried debugger, but it too did not help.. thank you in advance..
do this instead
const fetchTasks= async ()=>{
const res = await fetch('http://localhost:5000/tasks')
const data = res.json()
console.log("data", data)
}
fetchTasks()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.