-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic call to DC and some visual changes
- Loading branch information
Showing
6 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DC_API_BASE_URL = "https://api.datacommons.org/"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {DC_API_BASE_URL} from "../constants"; | ||
|
||
/** | ||
* Functions to access the Data Commons REST API | ||
*/ | ||
|
||
/** | ||
* Place Statistics - All | ||
* @param places | ||
* @param statVars | ||
* @constructor | ||
*/ | ||
// export function GetPlaceStatistics(places, statVars) { | ||
// let url = DC_API_BASE_URL + "stat/all"; | ||
// console.log(url); | ||
// const requestOptions = { | ||
// method: 'POST', | ||
// headers: {'Content-Type': 'application/json'}, | ||
// body: JSON.stringify({places: places, statVars: statVars}) | ||
// }; | ||
// return fetch(url, requestOptions); | ||
// }; | ||
|
||
export function GetPlaceStatistics(places, statVars) { | ||
let url = DC_API_BASE_URL + "stat/all"; | ||
console.log(url); | ||
const requestOptions = { | ||
method: 'POST', | ||
headers: {'Content-Type': 'application/json'}, | ||
body: JSON.stringify({places: places, statVars: statVars}) | ||
}; | ||
return fetch(url, requestOptions).then(response => { | ||
// Check if the request is 200 | ||
if (response.ok) { | ||
let data = response.json(); | ||
return data; | ||
} | ||
return Promise.reject(response); | ||
}); | ||
}; |