42 lines
912 B
JavaScript
42 lines
912 B
JavaScript
import React, { useState } from 'react'
|
|
import axios from 'axios';
|
|
export default function Create() {
|
|
const [name, setName] = useState('');
|
|
const postData = (e) => {
|
|
e.preventDefault();
|
|
//console.log('name: '+name);
|
|
const url='https://v1rgncy.api.swingbe.de/entities/create';
|
|
//console.log('url: '+url);
|
|
let data = new FormData();
|
|
data.append('name',name);
|
|
let config = {
|
|
method: 'post',
|
|
maxBodyLength: Infinity,
|
|
url: url,
|
|
data : data
|
|
};
|
|
axios.request(config)
|
|
.catch((error) => {
|
|
console.error('create:axios error: '+error);
|
|
});
|
|
};
|
|
return (
|
|
<div>
|
|
<h1>Create</h1>
|
|
<form onSubmit={postData}>
|
|
<label>
|
|
Enter name (input:{name}):
|
|
<input
|
|
placeholder='Name'
|
|
type="text"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
/>
|
|
</label>
|
|
<input
|
|
type="submit" />
|
|
</form>
|
|
</div>
|
|
);
|
|
};
|