Closed guilhermearaujo closed 7 years ago
@guilhermearaujo If you're trying to GET http://sharkywaters.com/api/boards
it's a fake URL used as example only. You can try playground
https://github.com/hyperoslo/Malibu/blob/master/Playground-iOS.playground/Contents.swift instead.
Oops, I actually used an existing URL, just forgot to change in the code above.
I ran the Playground and it worked. But in its examples it always use the Networking
method.
Compare these two tests:
// Test One
enum Endpoint: RequestConvertible {
case fetch
static let baseUrl: URLStringConvertible = "https://github.com"
static var headers: [String : String] {
return [:]
}
var request: Request {
return Request.get("/")
}
}
let networking = Networking<Endpoint>()
networking.request(.fetch)
.validate()
.done({ wave in
print("Success One")
})
.fail({ error in
print("Error One \(error) - \(error.localizedDescription)")
})
// Test Two
let request = Request.get("https://github.com/")
Malibu.request(request)
.validate()
.done({ wave in
print("Success Two")
})
.fail({ error in
print("Error Two \(error) - \(error.localizedDescription)")
})
They're both sending a GET request to the same route, with the same params, headers, etc (at least I thought so), but the first test ends with success, while the second fails, immediately, in fact:
Error Two invalidRequestURL - The operation couldn’t be completed. (Malibu.NetworkError error 4.) Success One
Using Charles to read the network traffic I can confirm that the second test doesn't even try to reach that route, the request simply doesn't start.
Yes, it seems like there is a bug with AnyEndpoint
. It could be fixed by making baseUrl
to be optional in RequestConvertible
, which actually makes sense I guess.
I am trying to run the first example:
and it always fails with the message
The operation couldn’t be completed. (Malibu.NetworkError error 4.)
. What am I doing wrong?