system
(system)
1
This topic was automatically generated from Slack. You can find the original thread here.
Raymond Camden : I know this is a dumb error on my part but - i’m building a test where I need PD to respond after 3 seconds. I did:
setTimeout(() => {
$respond({
status: 200,
headers: {
"Content-Type": "text/html; charset=UTF-8"
},
body: html,
})
},3000)
And I get an error saying $respond wasn’t used. What did I miss? (The html variable is defined earlier.)
system
(system)
2
Giao Phan : The timeout isn’t a promise so it’s not being awaited.
system
(system)
4
Raymond Camden : thank you
system
(system)
5
Giao Phan : Something like await new Promise(resolve => setTimeout(() => { // your code; resolve()}, 3000))
system
(system)
6
Raymond Camden : got it working - gracias
system
(system)
7
Raymond Camden : i love async/await, still kinda feeling my way with it
system
(system)
8
Giao Phan : Yeah, building the product has taught me many fun things about using/abusing it.