Generic parameter "Success" could not be inferred

I am attempting to get a json array from API and cant seem to get past this error.

Generic parameter 'Success' could not be inferred -- On line
@Published var tasks: [Task] = Array()

import Foundation

class ToDoViewModel: ObservableObject {

@Published var tasks: [Task] = Array()
@Published var username: String = ""
@Published var password: String = ""

@Published var error: APIError? // Added this
init() {

func fetchAllTasks() {
                parameters: ToDoRequest(
                    userid: 3212
            ).call { response in
                self.error = nil // Added this
                self.tasks = response
            } failure: { error in
                self.error = error // Added this


Any help is greatly appreciated.

Task needs two parameters one for success another for error. I'd recommend you to make the code compilable (e.g. comment out your "tasks" variable and its usage) and print(response) to see what type it has (or put a breakpoint and see the type in the debugger either in UI or via p response). If it is indeed an array of tasks you'll see the particular task type, like:

    [Task<XYZ, SomeErrorTypeHere>]

if so you make your tasks variable of that type:

@Published var tasks: [Task<XYZ, SomeErrorTypeHere>] = []