You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
If you are using Swift 5.5 in your project and your minimum target is iOS/tvOS 15+, macOS 12+ or watchOS 8+, you might want to use the `async` method `response` instead. For example, the usage might look something like this:
283
+
284
+
```Swift
285
+
let result =await provider.response(on: endpoint, decodeBodyTo: TranslationsResponse.self)
286
+
287
+
switch result {
288
+
caselet .success(translationsByLanguage):
289
+
// use the already decoded `[String: String]` result
290
+
291
+
caselet .failure(apiError):
292
+
// error handling
293
+
}
294
+
```
295
+
280
296
### Plugins
281
297
282
298
The initializer of `ApiProvider` accepts an array of `Plugin` objects. You can implement your own plugins or use one of the existing ones in the [Plugins](https://github.com/Flinesoft/Microya/tree/main/Sources/Microya/Plugins) directory. Here's are the callbacks a custom `Plugin` subclass can override:
@@ -331,8 +347,6 @@ public var decoder: JSONDecoder { JSONDecoder() }
331
347
332
348
publicvar encoder: JSONEncoder { JSONEncoder() }
333
349
334
-
publicvar plugins: [Plugin<Self>] { [] }
335
-
336
350
publicvar headers: [String: String] {
337
351
[
338
352
"Content-Type":"application/json",
@@ -351,7 +365,6 @@ So technically, the `Endpoint` type only requires you to specify the following 4
Copy file name to clipboardExpand all lines: Sources/Microya/Core/ApiProvider.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ open class ApiProvider<EndpointType: Endpoint> {
17
17
publicletplugins:[Plugin<EndpointType>]
18
18
19
19
/// The common base URL of the API endpoints.
20
-
publicletbaseUrl:URL
20
+
publicvarbaseUrl:URL
21
21
22
22
/// The mocking behavior of the provider. Set this to receive mocked data in your tests. Use `nil` to make actual requests to your server (the default).
0 commit comments