Below I mention a link for a React date range picker. It takes 2 parameters: one is date picker another one is date range picker. I want to include those two parameters in same URL to send a GET request to an API endpoint.
The final API endpoint URL should look like this:
http://127.0.0.1:8000/create_keyValue?key=<date_picker_value>&value=<date_range_value>
How can I update this API endpoint using the two date values selected by the user in this React component?
import React, { Component } from "react";
import axios from "axios";
import App from "./Date_range";
class PostList extends Component {
url = "http://127.0.0.1:8000/create_keyValue?key=";
constructor(props) {
super(props);
this.state = {
posts: [],
date: ""
};
}
componentDidUpdate() {
axios.get(this.url + this.state.date).then((response) => {
this.setState({
posts: response.data
});
console.log(response.data);
});
}
render() {
const { posts } = this.state;
return (
<div>
<App />
onChange={(e) =>
this.setState({ ...this.state, data: e.target.value })
}
{posts.length &&
posts.map((post) => <div key={post.id}>{post.id} </div>)}
</div>
);
}
}
export default PostList;
.,?