So basically I want to create a function that does a GET method in my API using an id received as params. As I'm coding a hook, I'm trying to export this function as well.
But, I'm suffering from this error:

Code:
import { api } from '../services/api';
interface Transaction{
_id: string,
name: string,
amount: number,
type: 'deposit' | 'withdraw'
createdAt: string,
}
interface TransactionContextData{
transactions: Transaction[]
getTransactionById: (transactionId: String) => Promise<Transaction>
}
const TransactionsContext = createContext<TransactionContextData>({} as TransactionContextData)
export function TransactionsProvider({children}:TransactionsProviderProps){
const [transactions, setTransactions] = useState<Transaction[]>([])
useEffect(() => {
getTransactions()
}, []);
async function getTransactionById(transactionId: String){
api.get(`transactions/${transactionId}`)
.then((reponse) => {return reponse.data});
}
return (
<TransactionsContext.Provider value={{ transactions, createTransaction, deleteTransaction, updateTransaction, getTransactions, getTransactionById}}>
{children}
</TransactionsContext.Provider>
)
}
export function useTransactions(){
const context = useContext(TransactionsContext)
return context
}
It just needs a return right before the api.get