Hi,
Can you guide me on how to add a delay before returning the result of a HTTP Request?
Here is the code I have currently, it works perfect, I just need to add the delay.
export function post_test(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
return request.body.json()
.then((body) => {
return wixData.query("Students")
.eq("studentMemberId", body.studentMemberId)
.eq("status", true)
.find()
.then((students) => {
if (students.items.length > 0) {
options.body = {
"redirect_call": "2222"
}
return ok(options)
} else {
options.body = {
"redirect_call": "1"
}
return ok(options)
}
})
})
.catch((error) => {
options.body = {
"error": error
};
return serverError(options);
})
}