migrate to axios, front-end part of configurable ServerAddress

This commit is contained in:
Aria Moradi
2021-03-07 22:25:29 +03:30
parent a59f974537
commit c1786f8e24
15 changed files with 182 additions and 114 deletions

View File

@@ -5,6 +5,7 @@
import React, { useContext, useEffect, useState } from 'react';
import SourceCard from '../components/SourceCard';
import NavBarTitle from '../context/NavbarTitle';
import client from '../util/client';
export default function Sources() {
const { setTitle } = useContext(NavBarTitle);
@@ -13,8 +14,8 @@ export default function Sources() {
const [fetched, setFetched] = useState<boolean>(false);
useEffect(() => {
fetch('http://127.0.0.1:4567/api/v1/source/list')
.then((response) => response.json())
client.get('/api/v1/source/list')
.then((response) => response.data)
.then((data) => { setSources(data); setFetched(true); });
}, []);