Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fetch('https://mywebsite.com/endpoint/', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- firstParam: 'yourValue',
- secondParam: 'yourOtherValue',
- })
- })
- var request = new XMLHttpRequest();
- request.open('POST', '/my/url', true);
- request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
- request.send(data);
- $.ajax({
- type: 'POST',
- url: '/some/url',
- data: data
- })
- .done(function(result) {
- this.clearForm();
- this.setState({result:result});
- }.bind(this)
- .fail(function(jqXhr) {
- console.log('failed to register');
- });
- npm install superagent --save
- import request from "../../node_modules/superagent/superagent";
- request
- .post('http://localhost/userLogin')
- .set('Content-Type', 'application/x-www-form-urlencoded')
- .send({ username: "username", password: "password" })
- .end(function(err, res){
- console.log(res.text);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement