I have written to following db query to get back all posts with a certain offset:

```
async function getPaginationPosts(start, size) {
    try {
        const posts = await knex("posts").select().where({
            deleted: false,
        }).orderBy("createdAt").limit(size).offset(start)
    } catch (e) {
        console.log(e.message)
        console.log(e.stack)
    }
    return posts
}

```

However, I am getting the following `Unhandled Promise Rejection`

```
(node:1824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: posts is n
ot defined
(node:1824) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejection
s that are not handled will terminate the Node.js process with a non-zero exit code.

```

My problem is that I do not get any further information about the error in the console.

Any suggestions from your site:

1. How to debug these types of rejections properly?
2. What is wrong with the above code?

Thank you in advance for your replies!

**Update**

I changed my function to the following:

```
async function getPaginationPosts(size, offset) {
    try {
        return await knex("posts").select().where({
            deleted: false,
        }).orderBy("createdAt").limit(size).offset(offset)
    } catch (e) {
        console.log(e.message)
        console.log(e.stack)
        return null
    }
}

```

Now I am getting the following exception:

```
(node:9096) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: start is n
ot defined

```

I do not use a variable `start` in my function.

Any suggestions what I am doing wrong here?