34 lines
638 B
TypeScript
34 lines
638 B
TypeScript
import React from 'react';
|
|
import axios from 'axios';
|
|
|
|
interface ButtonProps {
|
|
to: string;
|
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
text: string;
|
|
}
|
|
|
|
/* eslint-disable */
|
|
/**
|
|
* @return {jsx} The root component
|
|
*/
|
|
export default function Button({to, method, text}: ButtonProps) {
|
|
async function buttonFetch() {
|
|
console.log('buttonFetch');
|
|
console.log(to);
|
|
console.log(method);
|
|
axios({
|
|
method: method,
|
|
url: to,
|
|
withCredentials: true,
|
|
}).then((_res: any) => {
|
|
window.location.replace('/');
|
|
}).catch((_err: any) => {
|
|
});
|
|
}
|
|
|
|
return (
|
|
<button onClick={buttonFetch}>{text}</button>
|
|
);
|
|
}
|
|
/* eslint-enable */
|