Cleaned up usage of fetch

This commit is contained in:
2022-06-10 16:53:42 +01:00
parent ed01fe6db5
commit 490860159e
6 changed files with 11 additions and 22 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ docker-compose up --build
To set up this template in development mode: To set up this template in development mode:
1. Ensure mariadb is running in your development environment 1. Ensure mariadb is running in your development environment
2. Run `mariadb sql/create_database.sql` as the root user 2. Run `mariadb tools/create_database.sql` as the root user
3. Run `npm install` 3. Run `npm install`
4. Run `cp .envdev .env` and enter your details into the `.env` file 4. Run `cp .envdev .env` and enter your details into the `.env` file
5. Execute `npm run dev` 5. Execute `npm run dev`
+1 -3
View File
@@ -23,9 +23,7 @@ const Account = props => {
//grab the user's info //grab the user's info
useEffect(() => { useEffect(() => {
authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, { authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`)
method: 'GET'
})
.then(blob => blob.json()) .then(blob => blob.json())
.then(json => contactRef.current.checked = json.contact) .then(json => contactRef.current.checked = json.contact)
.catch(e => console.error(e)) .catch(e => console.error(e))
@@ -18,12 +18,7 @@ const NewsEditor = props => {
//run once //run once
useEffect(async () => { useEffect(async () => {
const result = await fetch(`${process.env.NEWS_URI}/news/metadata?limit=999`, { const result = await fetch(`${process.env.NEWS_URI}/news/metadata?limit=999`);
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
});
if (!result.ok) { if (!result.ok) {
const err = `${result.status}: ${await result.text()}`; const err = `${result.status}: ${await result.text()}`;
-4
View File
@@ -8,10 +8,6 @@ const NewsFeed = props => {
useEffect(() => { useEffect(() => {
//this... um... //this... um...
fetch(`${process.env.NEWS_URI}/news`, { fetch(`${process.env.NEWS_URI}/news`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
signal: aborter.current.signal //oh dear signal: aborter.current.signal //oh dear
}) })
.then(blob => blob.json()) .then(blob => blob.json())
+3 -4
View File
@@ -2,15 +2,14 @@ import React from 'react';
const Static = props => { const Static = props => {
return ( return (
<> <div className='page central'>
<header> <header>
<h1 className='text centered'>Credits</h1> <h1 className='text centered'>Credits</h1>
</header> </header>
<h2>MERN-template</h2> <h2 className='text centered'>MERN-template</h2>
<p>The <a href='https://github.com/krgamestudios/MERN-template'>MERN-template</a> developed by Kayne Ruse, KR Game Studios</p> <p>The <a href='https://github.com/krgamestudios/MERN-template'>MERN-template</a> developed by Kayne Ruse, KR Game Studios</p>
</> </div>
); );
}; };
export default Static; export default Static;
+5 -4
View File
@@ -2,11 +2,12 @@ import React from 'react';
const Static = props => { const Static = props => {
return ( return (
<header> <div className='page central'>
<h1 className="text centered">Privacy Policy</h1> <header>
</header> <h1 className="text centered">Privacy Policy</h1>
</header>
</div>
); );
}; };
export default Static; export default Static;