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 a, int b){
- calculatedValues.setA(a);
- calculatedValues.setB(b);
- System.out.println(calculatedValues.getA());
- System.out.println(calculatedValues.getB());
- return a * b;
- }
- 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: {
- a: this.state.a,
- b: this.state.b
- }
- }).then(response => {
- console.log(response);
- console.log(response.data);
- }).catch(error => {
- console.log(error.message);
- console.log(error.response);
- console.log(error.response.data);
- });
- }
- constructor (props) {
- super(props);
- this.state = {
- a: 0,
- b: 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