fix(api): Use POST instead of GET for API endpoints that mutate state (#877)

This commit is contained in:
TheCatLady
2021-02-08 20:27:48 -05:00
committed by GitHub
parent d163e29459
commit ff0b5ed441
16 changed files with 101 additions and 73 deletions

View File

@@ -63,7 +63,7 @@ const SettingsJobs: React.FC = () => {
}
const runJob = async (job: Job) => {
await axios.get(`/api/v1/settings/jobs/${job.id}/run`);
await axios.post(`/api/v1/settings/jobs/${job.id}/run`);
addToast(
intl.formatMessage(messages.jobstarted, {
jobname: job.name,
@@ -77,7 +77,7 @@ const SettingsJobs: React.FC = () => {
};
const cancelJob = async (job: Job) => {
await axios.get(`/api/v1/settings/jobs/${job.id}/cancel`);
await axios.post(`/api/v1/settings/jobs/${job.id}/cancel`);
addToast(intl.formatMessage(messages.jobcancelled, { jobname: job.name }), {
appearance: 'error',
autoDismiss: true,
@@ -86,7 +86,7 @@ const SettingsJobs: React.FC = () => {
};
const flushCache = async (cache: CacheItem) => {
await axios.get(`/api/v1/settings/cache/${cache.id}/flush`);
await axios.post(`/api/v1/settings/cache/${cache.id}/flush`);
addToast(
intl.formatMessage(messages.cacheflushed, { cachename: cache.name }),
{

View File

@@ -70,7 +70,7 @@ const SettingsMain: React.FC = () => {
const regenerate = async () => {
try {
await axios.get('/api/v1/settings/main/regenerate');
await axios.post('/api/v1/settings/main/regenerate');
revalidate();
addToast(intl.formatMessage(messages.toastApiKeySuccess), {

View File

@@ -212,19 +212,15 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
};
const startScan = async () => {
await axios.get('/api/v1/settings/plex/sync', {
params: {
start: true,
},
await axios.post('/api/v1/settings/plex/sync', {
start: true,
});
revalidateSync();
};
const cancelScan = async () => {
await axios.get('/api/v1/settings/plex/sync', {
params: {
cancel: true,
},
await axios.post('/api/v1/settings/plex/sync', {
cancel: true,
});
revalidateSync();
};