gpt4 book ai didi

swift - Moya 请求需要很长时间才能响应

转载 作者:行者123 更新时间:2023-11-30 10:37:06 24 4
gpt4 key购买 nike

Moya 请求在返回响应之前需要大约额外 7 秒的时间,而使用 Alamofire 或 URLSession 的任何请求则需要几毫秒......

var method: Moya.Method {
switch self {
case .foo:
return .get
case .bar:
return .get
}
}

var task : Task {
switch self {
case .foo:
return .requestParameters(parameters: [:], encoding: JSONEncoding.default)
case .bar:
return .requestParameters(parameters: [:], encoding: JSONEncoding.default)
}
}

最佳答案

disclaimer : this is answered directly using the option "Answer your own question – share your knowledge, Q&A-style"

使用URLEncoding和get请求,使得响应直接显示,这看起来像是moya中的一个错误。

var task : Task {
switch self {
case .foo:
return .requestParameters(parameters: [:], encoding: URLEncoding.default)
case .bar:
return .requestParameters(parameters: [:], encoding: URLEncoding.default)
}
}

关于swift - Moya 请求需要很长时间才能响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57732973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com