Good evening. I'm trying to create a simple translator for IOS. I'd like to use YandexTranslator API which requires the following request:
https://translate.yandex.net/api/v1.5/tr.json/translate ?
key=<API key>
& text=<text to translate>
& lang=<translation direction>
& [format=<text format>]
& [options=<translation options>]
& [callback=<name of the callback function>]
I'm using Alamofire and my code and my request look like the following:
@IBAction func translateButtonPressed(_ sender: Any) {
var newWord = wordField.text
Alamofire.request("https://translate.yandex.net/api/v1.5/tr.json/translate?lang=en-ru&text=\(newWord))&key=*hereGoesMyKey*", method: .post).responseJSON { response in
if let translatedWord = response.result.value{
print(translatedWord)
}
And my problem is that nothing happens, my JSON data is empty. Could you give me some clue how to fix my problem?