Skip to content

Instantly share code, notes, and snippets.

@9bany
Created December 21, 2020 10:55
Show Gist options
  • Save 9bany/de7563f20a77908d3b2e69bc67b98a5d to your computer and use it in GitHub Desktop.
Save 9bany/de7563f20a77908d3b2e69bc67b98a5d to your computer and use it in GitHub Desktop.
RequestClosure change url before call api in moya
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