Documents / @faasjs/func / useFunc
Function: useFunc()
useFunc<
TEvent
,TContext
,TResult
>(handler
):Func
<TEvent
,TContext
,TResult
>
Create a cloud function.
Type Parameters
• TEvent = any
• TContext = any
• TResult = any
Parameters
• handler
Returns
Func
<TEvent
, TContext
, TResult
>
Example
// pure function
export default useFunc(() => {
return () => {
return 'Hello World'
}
})
// with http
import { useHttp } from '@faasjs/http'
export default useFunc<{
params: { name: string }
}>(() => {
useHttp()
return ({ event }) => {
return `Hello ${event.params.name}`
}
})