Commit e14d8cc3 authored by David Haynes's avatar David Haynes 🙆

Work began on async fetching information from the API -> Components

- We need to remove the authorization feature on the API given that now,
all logged in users have the ability to create Go links
parent e46be336
Pipeline #3563 passed with stage
in 1 minute and 9 seconds
...@@ -2,6 +2,7 @@ import React from "react"; ...@@ -2,6 +2,7 @@ import React from "react";
import { Formik, Field, Form, ErrorMessage } from "formik"; import { Formik, Field, Form, ErrorMessage } from "formik";
import * as Yup from "yup"; import * as Yup from "yup";
import { PageTemplate } from "Components"; import { PageTemplate } from "Components";
import { GetAllGoLinks } from "../../Utils";
const SignupSchema = Yup.object().shape({ const SignupSchema = Yup.object().shape({
password: Yup.string() password: Yup.string()
...@@ -12,7 +13,24 @@ const SignupSchema = Yup.object().shape({ ...@@ -12,7 +13,24 @@ const SignupSchema = Yup.object().shape({
.required("Required") .required("Required")
}); });
const DebugCRUD = () => ( class DebugCRUD extends React.Component {
constructor(props) {
super(props);
this.state = { AllGoLinks: "", error: null };
}
async componentDidMount() {
GetAllGoLinks(this.props.authToken)
.then(data =>
this.setState({
AllGoLinks: data
})
)
.catch(reason => this.setState({ error: reason }));
}
render() {
return (
<PageTemplate> <PageTemplate>
<div> <div>
<h1>Debug CRUD Page</h1> <h1>Debug CRUD Page</h1>
...@@ -110,6 +128,8 @@ const DebugCRUD = () => ( ...@@ -110,6 +128,8 @@ const DebugCRUD = () => (
/> />
</div> </div>
</PageTemplate> </PageTemplate>
); );
}
}
export default DebugCRUD; export default DebugCRUD;
async function GetAllGoLinks(token) {
let response = await fetch("/auth/token");
let data = await response.json();
return data;
}
export default GetAllGoLinks;
import Routes from "./Routes"; import Routes from "./Routes";
import GetAllGoLinks from "./GetAllGoLinks";
export { Routes }; export { Routes, GetAllGoLinks };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment