import React, { useState } from 'react' 
import axios from 'axios';  
export default function Delete() {
    const [id, setId] = useState('');
    const postData = (e) => {
	e.preventDefault();
        console.log('id: '+id);
	/*
	const url='http://83.223.94.182:65535/entities/'+id+'/delete';
        console.log('url: '+url);
	let config = {
	    method: 'delete',
	    maxBodyLength: Infinity,
	    url: url,
	    headers: {}
	};
	axios.request(config)
	    .catch((error) => {
		console.error('create:axios error: '+error);
	    });
	*/
	/*
	let config = {
	    method: 'delete',
	    maxBodyLength: Infinity,
	    url: 'http://83.223.94.182:65535/entities/20/delete',
	    headers: { }
	};
	axios.request(config)
	    .then((response) => {
		console.log('rsp.data: '+response.data);
	    })
	    .catch((error) => {
		console.log(error);
	    });
	*/
	axios.delete('http://83.223.94.182:65535/entities/20/delete')
        .catch(error => {
            console.error('There was an error!', error);
        });
    };
    return (
	<div>
	    <h1>Delete</h1>
	    <form onSubmit={postData}>
		<label>
		    Enter id (input:{id}):
		    <input
			placeholder='Id'
			type="text"
			value={id}
			onChange={(e) => setId(e.target.value)}
		    />
		</label>
		<input
		    type="submit" />
	    </form>
	</div>
    );
};
