# Http request in a function node

**URL:** <https://discourse.nodered.org/t/http-request-in-a-function-node/57475>\
**Category:** Developing Nodes\
**Tags:** http-request\
**Created:** [30 January 2022 00:11 UTC](https://discourse.nodered.org/t/http-request-in-a-function-node/57475 "2022-01-30T00:11:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rollem1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rollem1/32/55324_2.png) [@Rollem1](https://discourse.nodered.org/u/Rollem1)\
**Post date:** [30 January 2022 00:11 UTC](https://discourse.nodered.org/t/http-request-in-a-function-node/57475/1 "2022-01-30T00:11:18Z")

</div>

Hi,

Apologies for the noob question if this is a simple one but I've tried a number of things and searched for something similar but I'm drawing a blank.

I am successfully accessing an online database through its API using discrete inject nodes into a HTTP Request node. I have to manually inject the respective commands in order to get the desired result. I would like to make this process simpler (more automated) and develop a custom node that handles obtaining and managing a token.

I need a way to make various https requests from within a single function node rather than use the HTTP request node. I have read about async / await calls and also promises but I don't know how to make the actual request execute from within the function. For example fetch is not supported here.

Is this possible and what is the best way to implement these asynchronous calls?

As an example a typical call using the http request node would be:-

```auto
     msg = {
        url: "https://api.glowmarkt.com/api/v0-1/virtualentity",
        method: "GET",
        headers: {
                contentype: "application/json",
                token: token,
                applicationId: applicationId},
        };
    
    return msg;
    }

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 March 2022 00:11 UTC](https://discourse.nodered.org/t/http-request-in-a-function-node/57475/2 "2022-03-31T00:11:28Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
