# Pre-request Script:TypeError: Cannot read property 'set' of undefined

**URL:** <https://community.postman.com/t/pre-request-script-cannot-read-property-set-of-undefined/32337>\
**Category:** Help Hub\
**Tags:** pre-request-script, typeerror\
**Created:** [February 8, 2022, 9:17am UTC](https://community.postman.com/t/pre-request-script-cannot-read-property-set-of-undefined/32337 "2022-02-08T09:17:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhilash78](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@abhilash78](https://community.postman.com/u/abhilash78)\
**Post date:** [February 8, 2022, 9:17am UTC](https://community.postman.com/t/pre-request-script-cannot-read-property-set-of-undefined/32337/1 "2022-02-08T09:17:09Z")

</div>

_My question_:  
I am getting following error in pre-request script

_Details (like screenshots)_:  
I am doing Postman Fundamentals Course by Nat Taylor on Pluralsight and came across this script to create variables to use them in later requests. Please see the script below and let me know if you see any issues and how to fix them.

pm.globals.set(“numberofUsers”, 2);

pm.globals.set(“currentUserCount”, 0);

pm.globals.set(“numberofWishlistAdds”, 4);

pm.globala.set(“currentWishlistcount”, 0);

pm.globals.set(“wishlistIds”, );

const getBooks= {

```
url: 'http://${pm.environment.get("host")}/books',

method: "GET",

header: "G-TOKEN:ROM831ESV"

```

}

pm.sendRequest(getBooks, function(err, books){

```
const ids = _.map(books.json(), function(book){

    return book.id;

});

pm.globals.set("bookIds", ids)

```

})

_How I found the problem_:

_I’ve already tried_:

---

<div class="post-metadata">

**Author:** ![kevinc-postman](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevinc-postman/32/12774_2.png) [@kevinc-postman](https://community.postman.com/u/kevinc-postman)\
**Post date:** [February 8, 2022, 8:13pm UTC](https://community.postman.com/t/pre-request-script-cannot-read-property-set-of-undefined/32337/2 "2022-02-08T20:13:55Z")

</div>

> [@abhilash78](#):
>
> pm.globala.set(“currentWishlistcount”, 0);

`globala`? 😄

Everything else looks like it should work as far as I can tell.
