Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get data requests #745

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _None._

### Bug Fixes

_None._
Fix data requests. [#745]

### Internal Changes

Expand Down
15 changes: 13 additions & 2 deletions WordPressKit/WordPressComRestApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ open class WordPressComRestApi: NSObject {
let progress = Progress.discreteProgress(totalUnitCount: 100)

Task { @MainActor in
let result = await self.perform(.get, URLString: URLString, parameters: parameters, fulfilling: progress)
let result: APIResult<AnyObject> = await self.perform(.get, URLString: URLString, parameters: parameters, fulfilling: progress)

switch result {
case let .success(response):
Expand Down Expand Up @@ -244,7 +244,7 @@ open class WordPressComRestApi: NSObject {
let progress = Progress.discreteProgress(totalUnitCount: 100)

Task { @MainActor in
let result = await self.perform(.post, URLString: URLString, parameters: parameters, fulfilling: progress)
let result: APIResult<AnyObject> = await self.perform(.post, URLString: URLString, parameters: parameters, fulfilling: progress)

switch result {
case let .success(response):
Expand Down Expand Up @@ -383,6 +383,17 @@ open class WordPressComRestApi: NSObject {
}
}

func perform(
_ method: HTTPRequestBuilder.Method,
URLString: String,
parameters: [String: AnyObject]? = nil,
fulfilling progress: Progress? = nil
) async -> APIResult<Data> {
await perform(method, URLString: URLString, parameters: parameters, fulfilling: progress) {
return $0
}
}

private func perform<T>(
_ method: HTTPRequestBuilder.Method,
URLString: String,
Expand Down