How to use the use-http/dist function in use-http

To help you get started, we’ve selected a few use-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / DLWorkspace / src / dashboard / src / pages / Jobs / index.tsx View on Github external
}
  },[])
  const[open, setOpen] = React.useState(false);
  const[openApprove, setOpenApprove] = React.useState(false);
  const[openPause, setOpenPause] = React.useState(false);
  const[openResume, setOpenResume] = React.useState(false);
  const[openKillWarn, setOpenKillWarn] = React.useState(false);
  const[openApproveWarn, setOpenApproveWarn] = React.useState(false);
  const[openPauseWarn, setOpenPauseWarn] = React.useState(false);
  const[openResumeWarn, setOpenResumeWarn] = React.useState(false);
  const[openUpdatePriority,setOpenUpdatePriority] = React.useState(false);
  const [openUpatePriorityWarn, setUpdatePriorityWarn] = React.useState(false);
  const { clusters } = React.useContext(ClusterContext);
  const [currentJob, setCurrentJob] = React.useState({jobId:'',cluster:'',priority: 100});
  const deleteUrl = `/api/clusters/`;
  const requestDelete =  useFetch(deleteUrl);
  const killJob = async () => {
    const body = {"status":"killing"};
    const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
    return data;
  }
  const approveJob = async () => {
    const body = {"status":"approved"};
    const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
    return data;
  }
  const pauseJob = async () => {
    const body = {"status":"pausing"};
    const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
    return data;
  }
  const resumeJob = async () => {

use-http

- useFetch - managed state, request, response, etc. [![](https://img.shields.io/badge/example-blue.svg)](https://codesandbox.io/s/usefetch-request-response-managed-state-ruyi3?file=/src/index.js) [![](https://img.shields.io/badge/video-red.svg)](https://w

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis