我想用 userProxy 判断是否加上.proxy(),应该怎么样优雅实现呢。
if (useProxy) {
data = await superAgent
.get(send.url)
.proxy(proxy)
.query(send.query)
.timeout({
response: 8000
})
.set({
'Content-Type': 'application/x-www-form-urlencoded'
})
} else {
data = await superAgent
.get(send.url)
.query(send.query)
.timeout({
response: 15000
})
.set({
'Content-Type': 'application/x-www-form-urlencoded'
})
}
这样应该可以吧,不太确定哪里有异步,都加个await总没错