import React from 'react';
import { Jumbotron, Button } from 'reactstrap';
import axios from 'axios';
import './App.css'
export default class Form extends React.Component{
constructor(){
super();
this.state={
fname:'',
lname:''
};
}
handleChange = event => {
this.setState({name:event.target.value});;
}
handleSubmit = event =>{
event.preventDefault();
const fname = this.state;
const lname = this.state;
axios.post('http://37692ae9.ngrok.io/api/addDocs',{fname,lname})
.then( res => {
console.log(res);
console.log(res.data);
})
.catch((error) =>{
alert(error);
})
}
render(){
return(
<div>
<div className="container">
<Jumbotron fluid>
<form onSubmit={this.handleSubmit}>
<label>
firstName:
<input type="text" name="fname" onChange={this.handleChange} />
</label>
<label>
lastName:
<input type="text" name="lname" onChange={this.handleChange} />
</label>
<Button type="submit">add</Button>
</form>
</Jumbotron>
</div>
</div>
)
}
}
please help me to post the two data in the url using axios whenever i was trying to send its not going..
the bug is Warning: Each child in an array or iterator should have a unique "key" prop.
i am very new to reactjs so please help me to solve this problem and make my code to execute