ios – Supabase integration with swift. Subject with “Additional trailing closure handed in name” error message

0
17
ios – Supabase integration with swift. Subject with “Additional trailing closure handed in name” error message


I’m making an attempt to create a Perform to fetch conversations for a consumer in SwiftUIachat app frontend to a Supabase db occasion. Sadly, Xcode produces the next error message: “Additional trailing closure handed in name” once I declare the func fetchConversations that you will see beneath.

I might be glad about any assist.

import Basis
import Supabase

class SupabaseManager {
    static let shared = SupabaseManager()

    let consumer: SupabaseClient

    non-public init() {
        let supabaseUrl = URL(string: "https://mysite.supabase.co")! // Substitute together with your Supabase URL
        let supabaseKey = "supabaseKey" // Substitute together with your Supabase public API key
        self.consumer = SupabaseClient(supabaseURL: supabaseUrl, supabaseKey: supabaseKey)
    }

    func registerWithPhone(e mail: String, password: String, completion: @escaping (Outcome) -> Void) {
            Process {
                do {
                    let authResponse = attempt await consumer.auth.signUp(e mail: e mail, password: password)
                    let consumer = authResponse.consumer
                    completion(.success(consumer))
                } catch {
                    completion(.failure(error))
                }
            }
        }

        func loginWithPhone(e mail: String, password: String, completion: @escaping (Outcome) -> Void) {
            Process {
                do {
                    let authResponse = attempt await consumer.auth.signIn(e mail: e mail, password: password)
                    let consumer = authResponse.consumer
                    completion(.success(consumer))
                } catch {
                    completion(.failure(error))
                }
            }
        }

        func logout(completion: @escaping (Outcome) -> Void) {
            Process {
                do {
                    attempt await consumer.auth.signOut()
                    completion(.success(()))
                } catch {
                    completion(.failure(error))
                }
            }
        }
        
    // Perform to fetch conversations for a consumer
    func fetchConversations(for userId: UUID, completion: @escaping (Outcome<[Conversation], Error>) -> Void) {
        consumer.database
            .from("Chats")
            .choose("chat_id, created_by, created_at")
            .eq("created_by", worth: userId.uuidString)
            .execute { lead to
                change consequence {
                case .success(let response):
                    do {
                        let conversations = attempt JSONDecoder().decode([Conversation].self, from: response.knowledge)
                        completion(.success(conversations))
                    } catch {
                        completion(.failure(error))
                    }
                case .failure(let error):
                    completion(.failure(error))
                }
            }
    }

}

I’ve tried re-formulate the func declaration with none luck.

Any assist could be nice.

Many thanks

LEAVE A REPLY

Please enter your comment!
Please enter your name here