Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @PostMapping(value = "/multiplyparams", consumes = {"application/x-www-form-urlencoded"}, produces = MediaType.APPLICATION_JSON_VALUE)
- @CrossOrigin(origins = "http://localhost:3000")
- public int MultiplyParams(int num1, int num2){
- calculatedValues.setA(num1);
- calculatedValues.setB(num2);
- System.out.println(calculatedValues.getA());
- System.out.println(calculatedValues.getB());
- return num1 * num2;
- }
- CalculateNumbers() {
- console.log(this.state.a);
- console.log(this.state.b);
- axios({
- method: 'post',
- headers: {
- 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
- },
- url: 'http://localhost:8080/multiplyparams',
- data: {
- 'num1': this.state.num1,
- 'num2': this.state.num2
- }
- }).then(response => {
- console.log(response);
- console.log(response.data);
- }).catch(error => {
- console.log(error.message);
- console.log(error.response.data);
- });
- }
- constructor (props) {
- super(props);
- this.state = {
- num1: 0,
- num2: 0
- }
- this.SetA = this.SetA.bind(this);
- this.SetB = this.SetB.bind(this);
- this.CalculateNumbers = this.CalculateNumbers.bind(this);
- }
Add Comment
Please, Sign In to add comment