Query data field for JavaScript Dependency | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Query data field for JavaScript Dependency
No permission to create posts
July 31, 2017
10:35 am
Avatar
jteindl

Silver
Members
Forum Posts: 8
Member Since:
July 6, 2017
sp_UserOfflineSmall Offline

Not sure if this is already doable...

 

In my JavaScript I have a number of variables as shown:
 
stop = new google.maps.LatLng(49.093914487013, -117.71569423377514)
waypts.push({
location: stop,
stopover: true
 
The line in Bold is what I need help with. I have data transmitted to Thingspeak. I have an API that allows me to select the exact value to query; what I need to know is how to use a GET statement (Or anything that would work) to have that Stopover line be True or False based on the result. So IF the result queried by the API is over 8, it's TRUE, if it's under it is false.
 
The API line looks like this: 
 
GET https://api.thingspeak.com/channels/****/fields/1.json?results=2
So How do I set that Bold field to query this and either be TRUE or FALSE based upon the result of this query?
 
If you need any more info please reply and I can fill in any blanks, but I'm reallllly needing some help here.
 
Thank you! 

 

August 8, 2017
3:23 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 210
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

You may be able to use jquery:

$.getJSON('https://api.thingspeak.com/channels/' + channel_id + '/fields/1.json?api_key=' + api_key , function(data) {

 

if (data.feeds==....)   //Do your check here

})

You may need to load the library first:

https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

celinabw2, FitoSprayscroma, LunnonGor, lancevl16, bernicenk60, veronicadq18

Administrators: Hans: 387, lee: 457