Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react';
- class Form extends Component {
- constructor(props) {
- super(props)
- this.state = {}
- }
- submitForm = (event) => {
- event.preventDefault()
- let oneData = document.getElementById('one')
- let twoData = document.getElementById('two')
- let data = {
- "one": oneData,
- "two": twoData
- }
- const url = "127.0.0.1:5000"
- fetch(url, {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify(data)
- }).then(
- response => {
- response.json()
- }
- ).then(
- data => {
- console.log(data)
- }
- )
- }
- render() {
- return (
- <form>
- <input type="text" placeholder="two" id="one"/>
- <input type="text" placeholder="one" id="two"/>
- <input type="submit" onClick={this.submitForm()}/>
- </form>
- )
- }
- }
- export default Form;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement