Questions tagged [moya]

Open source network abstraction layer that encapsulates calling Alamofire directly.

Features of Moya include:

  • Compile-time checking for correct API endpoint accesses.
  • Lets you define a clear usage of different endpoints with associated enum values.
  • Treats test stubs as first-class citizens so unit testing is super-easy.
207 questions
3
votes
2 answers

Logging response and request in Moya 14

Is there any way to log my request and response in Moya 14 without using verbose? container.register(NetworkLoggerPlugin.self) { r in NetworkLoggerPlugin(verbose: true) }.inObjectScope(.container) Thank you in advance.
Aira Samson
  • 226
  • 2
  • 10
3
votes
1 answer

Refreshing bearer token and using AccessTokenPlugin

For many of my endpoints, I require a bearer token to be passed with the request to authenticate the user. Because of that, I also need to refresh the user's token if it expires. I found this question to start me along, but I'm still unsure about…
user6724161
  • 195
  • 2
  • 15
3
votes
1 answer

unexpected EOF while looking for matching `'' (Xcode 11.1)

I was working on Xcode when I added the Moya cocoa pod. This error started since then and I never could build my project again. I already changed the Moya version, disintegrate the cocoa pod, but always the same error continues. I already saw the…
mmmaus
  • 45
  • 2
  • 6
3
votes
1 answer

RxSwift renew Authentication Token

Hy I'm trying to come up with a solution using Moya and RxSwift that renews an Authentication token and retries the requests. The problem is I have multiple requests going on at the same time, so lets say 10 requests fire while the Authentication…
Diogo Antunes
  • 2,241
  • 1
  • 22
  • 37
3
votes
1 answer

Handling JSON pagination, and adding data to a table view?

I'm getting a JSON response of the format: { "current_page":1, "data":[ { "id":1, "title":"Title 1" }, { "id":2, "title":"Title 2" }, { …
user6724161
  • 195
  • 2
  • 15
3
votes
2 answers

multipart form-data in moya with an int value in swift

I'm trying to send a form data with post request to API with moya. I searched the stack overflow and found some questions which they were similar to mine but I'm getting some error which I'll post it below. This and This are the two references that…
Am1rFT
  • 227
  • 5
  • 18
3
votes
2 answers

Swift Mapping Data to [String: Any]

I would like to convert a Data type to [String: Any], but the JSONSerialization tells me: Cannot force unwrap value of non-optional type 'Data' var json: [String: Any] do{ let jsonEncoder = JSONEncoder() …
rocklyve
  • 133
  • 1
  • 10
3
votes
1 answer

RxSwift sequential flatMap with Moya request

I currently have the following code func updateItems(_ observable: Observable) -> Observable{ return observable .concatMap({ (containingEntity) -> Observable in guard let…
y00rn
  • 31
  • 3
3
votes
2 answers

Moya request not started for one provider but works for another

I've inherited an RxSwift project which uses Moya. I have a task to move a request from one backend to another. Both backends have their TargetTypes sets up just fine as they're being used extensively elsewhere. The original request looked like…
Leon
  • 3,614
  • 1
  • 33
  • 46
3
votes
0 answers

How to cancel a long polling request with PromiseKit and Moya

I'm using PromiseKit and Moya to send a long polling request in the method bellow: func pullMessages() { let service = ChatServices() let request = service.pullMessages() self.request = request request.promise.then { [weak self]…
Zakaria
  • 1,040
  • 3
  • 13
  • 28
3
votes
1 answer

EVReflection + Moya + Realm + RxSwift - Could not create an instance for type dict

I'm stuck putting all of the above together. I'll appreciate if I can get any input. Here's my short setup: typealias RealmObject = Object /// Extension to ignore undefined keys when mapping extension RealmObject : EVReflectable { open override…
Andrej Jurkin
  • 2,216
  • 10
  • 19
3
votes
0 answers

Moya.Error/Swift How to get the response body of an error

I already asked this question but my wordings were poor. Assuming my API response code is 404, My goal is to get the JSON response body of that error API. Sure I can get the response code, but how about the response body?
Led
  • 662
  • 1
  • 19
  • 41
3
votes
2 answers

How to set basic auth username and password in Moya?

I've retrieved the username and password from a UITextField and now I want to set the username and password to every request Moya performs with basic auth. How do I do this?
Berry
  • 2,143
  • 4
  • 23
  • 46
3
votes
1 answer

Get response from Moya Response

I am using RxSwift and Moya to call request and get response. My code: NetworkManager.shared.request(api: .carrot2diamond, showLoading: false).subscribe({ (response) in // how to handle with response }).addDisposableTo(self.disposeBag) It shows…
Twitter khuong291
  • 11,328
  • 15
  • 80
  • 116
3
votes
1 answer

Make all endpoints to wait one exact endpoint

I am using Moya to handle HTTP operations and normally I have an refreshToken(). I am checking token if expired or not when a request is about happen but the problem is there can be a scenarios that more than one requests. If they are chained with…
Faruk
  • 2,269
  • 31
  • 42
1 2
3
13 14