# Error: Serverless-offline: handler for 'HelloWorldLambda' is not a function

**URL:** <https://forum.serverless.com/t/error-serverless-offline-handler-for-helloworldlambda-is-not-a-function/9323>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [September 12, 2019, 9:11pm UTC](https://forum.serverless.com/t/error-serverless-offline-handler-for-helloworldlambda-is-not-a-function/9323 "2019-09-12T21:11:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LSVH](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@LSVH](https://forum.serverless.com/u/LSVH)\
**Post date:** [September 12, 2019, 9:11pm UTC](https://forum.serverless.com/t/error-serverless-offline-handler-for-helloworldlambda-is-not-a-function/9323/1 "2019-09-12T21:11:21Z")

</div>

## My setup

Typescript + webpack, the part of the setup what works.

**serverless.yml**

```auto
service: hello-service
plugins:
- serverless-webpack
- serverless-offline
functions:
  HelloWorldLambda:
    handler: HelloService.add
      - 
        http:
          path: /hello/add
          method: get

```

**HelloService.ts**

```auto
import Service from "..."
import Hello from "..."

class HelloService extens Service<Hello> {
  async add(event: APIGatewayEvent, context: Context, cb: Callback): Promise<ApiGatewayResponse> {
    const entity = Service.getRequestedEntityProps(event);
    try {
       const result = await this.repository.addOrUpdate(entity);
       return Response.add(result.value());
    } catch (e) {
       return Response.fail(e);
    }
  }
  /* implementation of update, remove, etc... */
}

function getHandlers(service: Service<Hello>) {
  return {
    add: service.add,
    update: service.update,
    remove: service.remove,
  };
}

export default getHandlers(new HelloService());

```

## Full stacktrace

```auto
Serverless: GET /hello/add (λ: HelloWorldLambda)
Serverless: Error while loading HelloWorldLambda
Error: Serverless-offline: handler for 'HelloWorldLambda' is not a function
    at Object.createHandler (./node_modules/serverless-offline/src/functionHelper.js:221:11)
    at handler (./node_modules/serverless-offline/src/ApiGateway.js:485:40)
    at module.exports.internals.Manager.execute (./node_modules/@hapi/hapi/lib/toolkit.js:41:33)
    at Object.internals.handler (./node_modules/@hapi/hapi/lib/handler.js:46:48)
    at exports.execute (./node_modules/@hapi/hapi/lib/handler.js:31:36)
    at Request._lifecycle (./node_modules/@hapi/hapi/lib/request.js:312:68)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

```

## Steps to reproduce

1. Copy the setup.
2. Run `serverless offline start` on the command line.
3. Go to the url [http://localhost:3000/hello](http://localhost:3000/hello) to run the function.

## Expected result

The `getHandlers` function should return an object thus the HelloService will do a export default of an object with the keys add, update and remove. The value of a object property should be method of the service, what will work similar as a plain function.

---

<div class="post-metadata">

**Author:** ![rafaytaher](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rafaytaher/32/6150_2.png) [@rafaytaher](https://forum.serverless.com/u/rafaytaher)\
**Post date:** [August 31, 2021, 11:05am UTC](https://forum.serverless.com/t/error-serverless-offline-handler-for-helloworldlambda-is-not-a-function/9323/3 "2021-08-31T11:05:38Z")

</div>

did you find the solution to this problem?

---

<div class="post-metadata">

**Author:** ![pomSense](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pomsense/32/6456_2.png) [@pomSense](https://forum.serverless.com/u/pomSense)\
**Post date:** [December 28, 2021, 12:47am UTC](https://forum.serverless.com/t/error-serverless-offline-handler-for-helloworldlambda-is-not-a-function/9323/4 "2021-12-28T00:47:49Z")

</div>

I’m having the same issue and I’m also using the serverless-webpack plugin.

serverless.yml:

```auto
provider:
  name: aws
  runtime: nodejs12.x

package:
  individually: true
plugins:
  - serverless-webpack
  - serverless-deployment-bucket
  - serverless-offline

functions:
  - ${file(./resources/consumers.yml)}

```

./resources/consumers.yml

```auto
my-lambda:
  handler: handlers/domain/consumers/my-lambda.handler
  events:
    - http:
        path: v1/users
        method: POST
        cors: true
    - sqs:
        batchSize: 1
        arn:
          Fn::GetAtt:
            - MYQueue
            - Arn

```

handlers/domain/consumers/my-lambda.ts

```auto
export const handler: Handler = async (event: SQSEvent, context: Context) => {
  try {
    await processSQSRecords(Records)
  } catch (e) {
    console.log(e)
  }
}

```
