Skip to content

Commit

Permalink
Switch to request rather than axios
Browse files Browse the repository at this point in the history
  • Loading branch information
John Chipps-Harding committed Mar 27, 2021
1 parent 595c6a1 commit 1d4968a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions admin/src/containers/HomePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { Header } from "@buffetjs/custom";
import { LoadingBar } from "@buffetjs/styles";
import { faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import axios from "axios";
import { useGlobalContext } from "strapi-helper-plugin";
import { useGlobalContext, request } from "strapi-helper-plugin";

import pluginId from "../../pluginId";

Expand All @@ -19,9 +18,9 @@ const HomePage = () => {

useEffect(() => {
const checkBusy = async () => {
const { data } = await axios.get(`/${pluginId}/check`);
const { busy } = await request(`/${pluginId}/check`, { method: "GET" });

setBusy(data.busy);
setBusy(busy);
setReady(true);

checkTimeout.current = setTimeout(() => {
Expand All @@ -37,12 +36,14 @@ const HomePage = () => {
}, [checkNumber, setCheckNumber]);

const triggerPublish = async () => {
setBusy(data.success);
setBusy(true);
clearTimeout(checkTimeout.current);

const { data } = await axios.get(`/${pluginId}/publish`);
const { success } = await request(`/${pluginId}/publish`, {
method: "GET",
});

if (data.success) {
if (success) {
setTimeout(() => {
setCheckNumber(checkNumber + 1);
}, 20000);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-github-publish",
"version": "0.0.1",
"version": "0.0.2",
"description": "A plugin to easily trigger GitHub Actions workflows from Strapi.",
"strapi": {
"name": "GitHub Publishing",
Expand Down

0 comments on commit 1d4968a

Please sign in to comment.