Created
December 21, 2020 10:55
-
-
Save 9bany/de7563f20a77908d3b2e69bc67b98a5d to your computer and use it in GitHub Desktop.
RequestClosure change url before call api in moya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let requestClosure = { (endpoint: Endpoint, done: MoyaProvider.RequestResultClosure) in | |
do { | |
let queryItemToken = URLQueryItem(name: "key", value: "value") | |
var request = try endpoint.urlRequest() | |
var url = request.url | |
request.url = URL.addQueryParams(url: url!, newParams: [queryItemToken])! | |
done(.success(request)) | |
} catch { | |
done(.failure(MoyaError.underlying(error, nil))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment