Skip to content

Commit

Permalink
fix(front): conditional header fix, also replace fetch->axios (#51)
Browse files Browse the repository at this point in the history
* fix: conditional header fix, also replace fetch->axios

* fix: remove console statement
  • Loading branch information
ekelen authored Apr 8, 2020
1 parent 70cada0 commit ead7a38
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions web/src/ui/components/BuildList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useState, useEffect, useRef} from 'react';
import React, {useState, useEffect} from 'react';
import Card from './Card';
import axios from 'axios';

const BuildList = ({platformName, platformId}) => {
const [error, setError] = useState(null);
Expand All @@ -10,25 +11,24 @@ const BuildList = ({platformName, platformId}) => {
// TODO: Move these controllers out of component code
useEffect(() => {
const getBuilds = () =>
fetch(`${process.env.API_URL}/build-list?artifact_kind=${platformId}&`, {
method: 'GET',
headers: !process.env.YOLO_APP_PW
? new Headers({
Authorization: 'Basic ' + btoa(`${process.env.YOLO_APP_PW}`),
})
: null,
})
.then((res) => {
// TODO: Consume as stream (load incrementally)
return res.json();
axios
.get(`${process.env.API_URL}/build-list?artifact_kind=${platformId}&`, {
headers: process.env.YOLO_APP_PW
? {
Authorization: 'Basic ' + btoa(`${process.env.YOLO_APP_PW}`),
}
: {},
})
.then(
(result) => {
const {
data: {builds},
} = result;
setIsLoaded(true);
setBaseURL(
`${document.location.protocol}//${document.location.host}`
);
setItems(result.builds);
setItems(builds);
},
(error) => {
setIsLoaded(true);
Expand Down

0 comments on commit ead7a38

Please sign in to comment.