Skip to content

Commit

Permalink
Merge pull request #16 from joselinoneto/15-query-string-params
Browse files Browse the repository at this point in the history
fix query string
  • Loading branch information
joselinoneto authored Jun 2, 2021
2 parents b2410d2 + 4007932 commit 3dfb604
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 10 additions & 12 deletions Sources/ToolboxAPIClient/BaseNetworkWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ public class BaseNetworkWorker<T> where T: Codable {

private var finalUrl: URL {
get {
// var components = URLComponents()
// components.scheme = "http"
// components.host = "localhost"
// components.port = 8080
// components.path = "/professions"
//// //components.queryItems = targetType.queryString
// guard let url = components.url else {
// preconditionFailure("Invalid URL components: \(components)")
// }
// return url
let url = targetType.baseURL.appendingPathComponent(targetType.path)
return url
var components = URLComponents(url: targetType.baseURL, resolvingAgainstBaseURL: true)
print(targetType)
if targetType.queryString.count > 0 {
components?.queryItems = targetType.queryString
}
guard let url = components?.url else {
preconditionFailure("Invalid URL components")
}
let finalUrl: URL = url.appendingPathComponent(targetType.path)
return finalUrl
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension StoryTarget: TargetType {
}

public var baseURL: URL {
URL(string: "https://astronomia-api.herokuapp.com/")!
URL(string: "https://astronomia-staging.herokuapp.com/")!
}

public var path: String {
Expand All @@ -59,6 +59,6 @@ extension StoryTarget: TargetType {
}

public var headers: [String : String]? {
["Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiIxMTY3MDNFOS1CRjdFLTQyMEEtQjhFRi1BMjY1MTI5NzlEMjEiLCJzdWIiOiJhc3Ryb25vbWlhX2FwaSIsImV4cCI6NjQwOTIyMTEyMDAsImFkbWluIjp0cnVlfQ.D-ZoYLLVfdGaXrIfVl5BlKslN2oFezBpa0PguKCXmhs"]
["Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaWQiOiI4NUNFMjJCMi0xMzExLTRCRjgtOUIwMy1GQTFCREYzQkUyOTIiLCJzdWIiOiJhc3Ryb25vbWlhX2FwaSIsImV4cCI6NjQwOTIyMTEyMDAsImFkbWluIjp0cnVlfQ.0AR701FCTjs9A90Nev5GGgVujnXwV4wgSkCrqjVkhYg"]
}
}

0 comments on commit 3dfb604

Please sign in to comment.