# Can Execute Javascript Get Values from API request

**URL:** <https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804>\
**Category:** SeleniumLibrary\
**Created:** [16 November 2021 12:07 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804 "2021-11-16T12:07:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![robot](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@robot](https://forum.robotframework.org/u/robot)\
**Post date:** [16 November 2021 12:07 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804/1 "2021-11-16T12:07:01Z")

</div>

Im am trying to get the token coming from a request using Execute javascript, I am not sure if this is possible using that Keyword.  
See code below:

 ![Screen Shot 2021-11-16 at 8.03.50 PM](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/5/58c488dec2fea470fd2a48a1c3ae763e05279af8.png)

when looking at the report, it did not return an error but did not return any value.

 ![Screen Shot 2021-11-16 at 8.05.43 PM](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/f/ffb9335d5e8d45b057bf251b60874e601fed6d1c.png)

is there a way to extract the value of that JS snippet using robot framework?

---

<div class="post-metadata">

**Author:** ![Wolfe1](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/wolfe1/32/3386_2.png) [@Wolfe1](https://forum.robotframework.org/u/Wolfe1)\
**Post date:** [16 November 2021 15:29 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804/2 "2021-11-16T15:29:41Z")

</div>

I could be wrong but this should just be:

```
${token}= SeleniumLibrary.Execute Javascript window.gapi.......

```

And then you have your token stored in ${token} provided that is what is returned.

---

<div class="post-metadata">

**Author:** ![robot](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@robot](https://forum.robotframework.org/u/robot)\
**Post date:** [17 November 2021 02:32 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804/3 "2021-11-17T02:32:28Z")

</div>

hi Wolfe1,

thank you for the suggestion, did that already before posting this question, sadly it did not return any values.

---

<div class="post-metadata">

**Author:** ![aaltat](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/aaltat/32/15_2.png) [@aaltat](https://forum.robotframework.org/u/aaltat)\
**Post date:** [17 November 2021 12:19 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804/4 "2021-11-17T12:19:32Z")

</div>

I think there should be `return` statement in the JavaScript so that it would give the value back.

---

<div class="post-metadata">

**Author:** ![robot](https://avatars.discourse-cdn.com/v4/letter/r/7993a0/32.png) [@robot](https://forum.robotframework.org/u/robot)\
**Post date:** [18 November 2021 07:27 UTC](https://forum.robotframework.org/t/can-execute-javascript-get-values-from-api-request/2804/5 "2021-11-18T07:27:09Z")

</div>

Do you have any idea how should i do that? not really sure on where the return should be put. Thanks!
