I have this code - where I'm trying to pass in a string title:
let GetData: (title: string) => Promise<APIStates<Series[]>>;
if (process.env["REACT_APP_SERVICE_VERSION"] === "development") {
GetData = useGetDataServiceDummy(title)
}
However I keep getting 2 errors and can't figure out the syntax to resolve it:
Cannot find name 'title'Promise<APIStates<Series[]> is not assignable to (title: string) => Promise<APIStates<Series[]>
Could someone please help me with the syntax to get around this error.
And for reference useGetDataServiceDummy
export async function useGetDataServiceDummy(title: string): Promise<APIStates<Series[]>> {
// do soemthing with `title`
return { status: "loaded", payload: dummyData };
}
Any help would be appreciated.
Thanks.
GetDataas a function, but assigning to it the promise (the function's return value)title- in shown part of code it is not defined..useGetDataServiceDummywill return aPromiseand it just returns a regularObject. 2)titleis literally not defined in the snippet you provided 3) You're assigning a return type of auseGetDataServiceDummytoGetDataby calling it.(title)and you said it will be a function and not aPromise=>: (title: string) => Promise<APIStates<Series[]>>