Confused by the Swift API docs

Hi there, I just started to read up on Algolia yesterday and I’m having trouble trying to implement it into my application. So I had the let client = ... and the let index = ... declarations outside of my class right under the import AlgoliaSearchClient line of code, since I couldn’t declare it inside the class without an error. I actually put a public access level before the let index so i could use it in one of my IBAction functions inside of my class.

Here is the IBAction function :

        @IBAction public func createEventButton(_ sender: UIButton) {

    let event: Event = .init(eventName: nameTextField.text!)


    let error = validateFields()
    
    if error != nil {
        showError(error!)
    } else {
        
        db.collection("school_users/\(user?.uid)/events").addDocument(data: ["event_name": nameTextField.text, "event_date": dateTextField.text, "event_cost": costTextField.text, "for_grades": gradesTextField.text, "school_id": schoolIDTextF.text]) { (error) in
            if error != nil {
                self.showError("There was an error trying to add user data to the system.")
            } else {
                
                self.dismiss(animated: true, completion: nil)
            }
        }
        try Attend.index.saveObject(event, autoGeneratingObjectID: true) { result in
            if case .success(let response) = result {
                print("Response: \(response)")
            }
        }

        
    }
}

So when I tried to press the button, the event added to my Firestore database, but I got this huge error in the console.

After seeing this I wasn’t quite sure how to fix this since the documentation was already confusing enough. If anyone can guide me through this issue that would be great thanks.

Hi @dantesauder ,

Looks like there is a problem with the host name in the URL.
Did you properly set the application ID and the api key while initialising your search client instance? Make sure you application ID is not an empty string.