aboutsummaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/App.js4
-rw-r--r--frontend/src/Button.js9
-rw-r--r--frontend/src/SECAPIData.js75
3 files changed, 63 insertions, 25 deletions
diff --git a/frontend/src/App.js b/frontend/src/App.js
index 73ec59e..cf89bf0 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -1,10 +1,6 @@
import './App.css';
import SECAPIData from "./SECAPIData";
-/*
-App is the main react component that contains all the other maps components
-*/
-
function App() {
return (
diff --git a/frontend/src/Button.js b/frontend/src/Button.js
new file mode 100644
index 0000000..9aba266
--- /dev/null
+++ b/frontend/src/Button.js
@@ -0,0 +1,9 @@
+import { AwesomeButton } from "react-awesome-button";
+import "react-awesome-button/dist/styles.css";
+
+
+function Button(props) {
+ return <AwesomeButton type="primary" onPress={props.onPress}>GET DATA</AwesomeButton>;
+}
+
+export default Button; \ No newline at end of file
diff --git a/frontend/src/SECAPIData.js b/frontend/src/SECAPIData.js
index daa653a..987378c 100644
--- a/frontend/src/SECAPIData.js
+++ b/frontend/src/SECAPIData.js
@@ -1,34 +1,66 @@
import React, {useState, useRef} from 'react';
+import Button from './Button';
+
function SECAPIData() {
- const [filedAt, setFiledAt] = useState("");
- const [xml, setXML] = useState("");
+
+ const [dataToBackend, setDataToBackend] = useState([]);
+ const [displayData, setDisplayData] = useState("");
const requestData = () => {
- const toSend = {
- filedAt : filedAt,
- xml : xml,
- };
+ let date = new Date()
+ let today = date.toISOString().slice(0, 10);
+
+ let pastDate = new Date();
+ pastDate.setDate(date.getDate() - 14);
+ let past = pastDate.toISOString().slice(0, 10);
- let axiosConfig = {
+ fetch("https://api.sec-api.io?token=defaad59a1b9b82e688d2761357c4c674dc16bd16b8350090254fe53288ad1be", {
+ method: "POST",
+ body: JSON.stringify({
+ "query": { "query_string": { "query": "formType:4 AND filedAt:{"+ past +" TO "+ today +"} AND formType:(NOT \"N-4\") AND formType:(NOT \"4/A\")" } },
+ "from": "0",
+ "size": "1000",
+ "sort": [{ "filedAt": { "order": "desc" } }]
+ }),
headers: {
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- "Access-Control-Allow-Origin": "*",
- }
- };
-
- axios({
- method: 'post',
- url: 'http://localhost:4567/',
- headers: axiosConfig,
- data: toSend
+ "Content-Type": "application/json"
+ },
+ credentials: "same-origin"
+ })
+ .then(res => res.json())
+ .then(data => {
+ let list = new Array();
+ data.filings.forEach(function(filing) {
+ if (filing.ticker == "") {
+ list.push(filing.filedAt);
+ list.push(filing.documentFormatFiles[1].documentUrl);
+ }
+ })
+ setDataToBackend(list);
})
-
- .then(response => {
+ .catch(function (error) {
+ console.log(error);
+ });
+
+ fetch("http://localhost:4567/data", {
+ method: "POST",
+ body: JSON.stringify({
+ "data" : {dataToBackend}
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ credentials: "same-origin"
+ })
+
+ .then(response => {
+ setDisplayData(JSON.stringify(response));
+ console.log(response);
})
.catch(function (error) {
console.log(error);
@@ -37,8 +69,9 @@ function SECAPIData() {
return (
<div>
- <h1 >SECAPIData</h1>
- <Button onPress={requestData}>GETDATA</Button>
+ <h1>SECAPIData</h1>
+ <Button onPress={requestData}></Button>
+ <p>DISPLAY DATA: {displayData}</p>
</div>
);
}