The proper implementation looks kinda bulky to me. Are you not allowed to use promises? Feels more like a naive solution for anyone who has few months of experience with javascript or is it cheating?
const PromiseQueue = {
queue: Promise.resolve(true),
sendOnce(request) {
return new Promise((resolve, reject) => {
this.queue = this.queue
.then(request)
.then(resolve)
.catch(reject)
})
}
}