53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
import React, { useState } from 'react'
|
|
import axios from 'axios';
|
|
|
|
export default function Update() {
|
|
const [name, setName] = useState('');
|
|
const [id, setId] = useState('');
|
|
const postData = (e) => {
|
|
e.preventDefault();
|
|
console.log('postData() id: '+id);
|
|
console.log('postData() name: '+name);
|
|
const url='http://83.223.94.182:65535/entities/'+id+'/update';
|
|
console.log('postData() url: '+url);
|
|
let data = new FormData();
|
|
data.append('postData() 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>Update</h1>
|
|
<form onSubmit={postData}>
|
|
<label>
|
|
Enter id (input:{id}):
|
|
<input
|
|
placeholder='Enter Id'
|
|
type="text"
|
|
value={id}
|
|
onChange={(e) => setId(e.target.value)}
|
|
/>
|
|
</label>
|
|
<label>
|
|
Enter name (input:{name}):
|
|
<input
|
|
placeholder='Enter Name'
|
|
type="text"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
/>
|
|
</label>
|
|
<input type="submit" />
|
|
</form>
|
|
</div>
|
|
);
|
|
};
|