Closed AlbanPerli closed 7 years ago
Hello @AlbanPerli,
Concerning the "ambiguous" parameter. This is because post
is generic, which has lots of advantages, like keeping the api small, but the drawback is needing to give it the type :)
This yields an error :
ws.post("", params: ["":""]).then { json in }
while the following doesn't :
ws.post("", params: ["":""]).then { (json:JSON) in { }
The way it's usually meant to be used is "wrapped" in a function that gives the type.
func postSomething() -> Promise<JSON> {
return ws.post("", params: ["":""])
}
// later
postSomething().then { json in
}
As for the second error, this compiles fine on my end :/ I am trying to reproduce it with no luck,
Hope it helps :)
De rien!
Thanks for the quick response! The generic part is what I'm looking for :D
I've read the issue #11 And tried it, but I've now this error: Cannot invoke 'then' with an argument list of type '((JSON) -> () -> ())'
And of course, still the same error for the test()
method...
It comes from cocoapods,
pod 'ws', '~> 2.0'
and it's build with the latest xCode.
I don't understand why the get()
method is working, it seems to be build the same way, right?
@s4cha ...Found!
the Arrow framework has a JSON
Class.
I'm using SwiftyJSON, with a Class named JSON
too.
It leads to strange behaviours, with poor error description.
Without this class, everything's work as expected with ws
It could be interesting to make ws compatible with SwiftyJSON Used with SwiftyJSONAccelerator it could be even faster to get swift model from json API.
I'll look about it.
Thank!
@AlbanPerli glad you found it! Have you tried specifying Arrow.JSON
to remove the type ambiguity?
WS is meant to work with Arrow out of the box but Swiftjson being the goto json parser for a lot of ios devs Iād be interested to support it too. Maybe we could colalborate on it?
Cheers,
Sure @s4cha š At the end of august.
Any update on this?
Hi, first, thanks for your good job! (especially with Stevia š )
I wanted to use your lib (v2.0.4) to post some datas but...
When I try this:
Produce error: Ambiguous use of 'post(_:params:)'
And when used like in the
get
example:Produce error: No 'post' candidates produce the expected contextual result type 'Promise'
Any ideas? Did I miss something?
Tell me if I can help!
Merci :)