feat(react-crud): refactor
This commit is contained in:
parent
5cf964b74d
commit
249dd82d97
|
@ -1,16 +1,17 @@
|
|||
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('id: '+id);
|
||||
console.log('name: '+name);
|
||||
console.log('postData() id: '+id);
|
||||
console.log('postData() name: '+name);
|
||||
const url='http://83.223.94.182:65535/entities/'+id+'/update';
|
||||
console.log('url: '+url);
|
||||
console.log('postData() url: '+url);
|
||||
let data = new FormData();
|
||||
data.append('name',name);
|
||||
data.append('postData() name',name);
|
||||
let config = {
|
||||
method: 'post',
|
||||
maxBodyLength: Infinity,
|
||||
|
@ -29,7 +30,7 @@ export default function Update() {
|
|||
<label>
|
||||
Enter id (input:{id}):
|
||||
<input
|
||||
placeholder='Id'
|
||||
placeholder='Enter Id'
|
||||
type="text"
|
||||
value={id}
|
||||
onChange={(e) => setId(e.target.value)}
|
||||
|
@ -38,14 +39,13 @@ export default function Update() {
|
|||
<label>
|
||||
Enter name (input:{name}):
|
||||
<input
|
||||
placeholder='Name'
|
||||
placeholder='Enter Name'
|
||||
type="text"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
type="submit" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue