Skip to content

Instantly share code, notes, and snippets.

@amenpunk
Created March 3, 2022 04:50
Show Gist options
  • Save amenpunk/e5deecde7ec1491725505d737dbb79bf to your computer and use it in GitHub Desktop.
Save amenpunk/e5deecde7ec1491725505d737dbb79bf to your computer and use it in GitHub Desktop.
let body = {
"nombre" : "Lucas Joel",
"apelidos" : "Juarez Jocon",
"telefono" : "45435345",
"direccio": "4 calle zona 1",
"fechacumple": "2021-01-01",
"nit": "5345435",
"cui": "555555",
"email": "garzon2@mail.com",
"username": "garzo2n@mail.com",
"pwd": "123456"
}
let url = 'http://204.48.25.93:8081/registro'
// let url = 'http://psicoadmin.ditca.org:8081/registro'
const V1 = async (url, body) => {
let response = await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body : JSON.stringify(body)
})
let req = await response.json();
console.log('register request',req )
}
const V2 = (url, data) => {
$.ajax({
type:"POST",
url:url,
data: JSON.stringify(data),
contentType: 'application/json',
success: function(res) {
console.log('jquery resp',res);
console.log("Added");
}.bind(this),
error: function(xhr, status, err) {
console.error(xhr, status, err.toString());
}
})
}
// V1(url, body);
V2(url, body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment