[add] fetch call to database

This commit is contained in:
Daniel 2017-09-02 23:28:57 -04:00
parent 9c0e77ab42
commit df8e32f1cb
4 changed files with 64 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,10 @@
{
"name": "chaoticbackup-portal",
"version": "0.0.1",
"version": "0.0.2",
"description": "Chaotic Backup Portal to Perim",
"scripts": {
"start": "webpack-dev-server -d --inline --host 0.0.0.0 --history-api-fallback --progress"
"start": "webpack-dev-server -d --inline --host 0.0.0.0 --history-api-fallback --progress",
"build": "webpack -p"
},
"repository": {
"type": "git",
@ -15,7 +16,8 @@
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-interactive": "^0.5.1",
"react-router": "^3.0.0"
"react-router": "^3.0.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"babel-core": "^6.21.0",

View File

@ -1,18 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';
import URLS from '../URLS';
import 'whatwg-fetch';
const propTypes = {
children: PropTypes.element,
};
function Creatures({children}) {
return (
<div>
{children||
<div>test</div>
}
</div>
);
fetch(URLS.Creature_Overworld)
.then(function(response) {
return response.json();
}).then(function(json) {
console.log('parsed json', json.feed.entry);
}).catch(function(ex) {
console.log('parsing failed', ex);
})
return (
<div>
{children||
<div>test</div>
}
</div>
);
}
Creatures.propTypes = propTypes;

33
src/components/URLS.js Normal file
View File

@ -0,0 +1,33 @@
import React from 'react';
class URLS {
static base_url = "https://spreadsheets.google.com/feeds/list/";
static data_format = "/od6/public/values?alt=json";
// + "/od6/public/basic?alt=json"; // Alternate data format
constructor() {}
static path(spreadsheetID) {
return URLS.base_url + spreadsheetID + URLS.data_format;
}
get Creature_Overworld() {
return URLS.path("1Z4_MmlV7uE34nLzrcxslqQKRwL4OBXNA15s7G8eteXU");
}
// Singleton
static instance = null;
static createInstance() {
var object = new URLS();
return object;
}
static getInstance() {
if (!URLS.instance) {
URLS.instance = URLS.createInstance();
}
return URLS.instance;
}
}
export default URLS.getInstance();