# DropDownList + Data API

**URL:** https://discourse.nodered.org/t/dropdownlist-data-api/22829
**Category:** Developing Nodes
**Created:** [9 March 2020 07:35 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829 "2020-03-09T07:35:41Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [9 March 2020 07:35 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/1 "2020-03-09T07:35:42Z")

</div>

I want to get data from google API to Dropdownlist on new node. Can I use AJAX to call request and recieve data to my dropdownlist? If yes, how to I use it. Thank you~

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [9 March 2020 09:09 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/2 "2020-03-09T09:09:24Z")

</div>

Yes, you can use jQuery or native JavaScript AJAX calls to do this. Please refer to the appropriate jQuery or JavaScript documentation on the details.

You will find plenty of examples in existing nodes. uibuilder for example has several calls although they are requests back to Node-RED. However the principle is exactly the same.

---

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [9 March 2020 10:20 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/3 "2020-03-09T10:20:09Z")

</div>

Sorry, I don't see any dropdown list in uibuilder

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca3e67efb99ea6026be2c0ae4f14bfeed76578e1.png)

---

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [9 March 2020 10:22 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/4 "2020-03-09T10:22:35Z")

</div>

In addition, Can I get oauth token from file .JS?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [9 March 2020 17:36 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/5 "2020-03-09T17:36:51Z")

</div>

If you click on "Edit Source Files", you will see some drop-downs.

In addition, I use API's calls to populate the list of libraries that you see when you click on "Manage front-end libraries".

Check out the html file and you will see the code that calls the API's.

> [@taminhhienmor](#):
>
> Can I get oauth token from file .JS?

You will need to explain more I'm afraid. What are you trying to achieve? In the Node-RED editor, authentication and authorisation are handled internally. If you specify an API on the admin server, you can pass an authentication level that users must possess in order to be able to access the API. Have a look at uibuilder's js file, the API's are defined at the end.

However, you should note a recent thread in the forum about whether or not the admin authorisation works the way it is supposed to as a few of us have experienced odd issues.

> [@Uibuilder uibindex not working](https://discourse.nodered.org/t/uibuilder-uibindex-not-working/22116):
>
> I'm running uibuilder on ubuntu installed on a user account $home/.node-red/uibuilder When I tried to access uibindex via Show Detailed Information icon, I got this error msg Unauthorized May I know how do I troubleshoot this issue ? Thanks

---

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [10 March 2020 04:28 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/6 "2020-03-10T04:28:58Z")

</div>

I intend to create drop-down list to show list email from API google calendar, I'm using oauth based on node-red-node-google to request API. I want to call api google in ` oneditprepare: function() {}` by AJAX

```auto
oneditprepare: function() {
$.ajax({
        headers: {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + **node.googleAPI.credentials.accessToken** (I want to get this from file google.js in node-red-node-google)
        },
        url: "https://www.googleapis.com/calendar/v3/users/me/calendarList",
        method: 'GET'
    }).then(function(data) {
        $("#node-input-dropdown").append('<option>data</option>');
    });
}

```

I wonder if you could help me with this?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [10 March 2020 09:15 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/7 "2020-03-10T09:15:48Z")

</div>

I haven't used the Google API's for quite a while I'm afraid. So I don't know off the top of my head.

However, perhaps this will help?

> <https://stackoverflow.com/questions/20933965/google-calendar-events-list/21000850#21000850>

---

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [11 March 2020 02:12 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/8 "2020-03-11T02:12:09Z")

</div>

Thank you for suggest. But, Do you know how to get variable or function from .js file to .html file?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 March 2020 06:59 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/9 "2020-03-11T06:59:45Z")

</div>

Use a file in node to read your file the send the contents to UI builder. The extensive information that is included with UI builder (and the wiki) shows you how to send values into UI builder.

---

<div class="post-metadata">

### Author: ![taminhhienmor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taminhhienmor/32/19779_2.png) [@taminhhienmor](https://discourse.nodered.org/u/taminhhienmor)
#### Post date: [11 March 2020 07:12 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/10 "2020-03-11T07:12:05Z")

</div>

Sorry, I don't understand what you mean. Can you talk detail about this?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 March 2020 21:10 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/11 "2020-03-11T21:10:02Z")

</div>

> [@taminhhienmor](#):
>
> Thank you for suggest. But, Do you know how to get variable or function from .js file to .html file?

Not sure what you mean?

My last post was about using the Google API's directly. You should be able to do that directly in your node's html file in the script section.

---

<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: [10 May 2020 21:10 UTC](https://discourse.nodered.org/t/dropdownlist-data-api/22829/12 "2020-05-10T21:10:03Z")

</div>

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