|
|
@@ -1,3 +1,35 @@
|
|
|
+import $ from 'jquery'
|
|
|
+
|
|
|
+export 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");
|
|
|
+ },
|
|
|
+ error: function(xhr, status, err) {
|
|
|
+ console.error(xhr, status, err.toString());
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+export 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 )
|
|
|
+}
|
|
|
+
|
|
|
export class Service {
|
|
|
|
|
|
constructor(path){
|
|
|
@@ -7,26 +39,7 @@ export class Service {
|
|
|
// this.api = 'http://psicoadmin.ditca.org:8081/user?user=patrik&password=12345'
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- async browser(){
|
|
|
- fetch("http://psicoadmin.ditca.org:8081/registro", {
|
|
|
- "headers": {
|
|
|
- "accept": "*/*",
|
|
|
- "accept-language": "en-US,en;q=0.9,es;q=0.8",
|
|
|
- "cache-control": "no-cache",
|
|
|
- "pragma": "no-cache",
|
|
|
- "sec-gpc": "1"
|
|
|
- },
|
|
|
- "referrer": "http://localhost:3000/",
|
|
|
- "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
- "body": null,
|
|
|
- "method": "POST",
|
|
|
- "mode": "cors",
|
|
|
- "credentials": "omit"
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- async post_(body){
|
|
|
+ async post(body){
|
|
|
console.log('body >> ', body)
|
|
|
let response = await fetch(this.url, {
|
|
|
method: "POST",
|
|
|
@@ -35,43 +48,5 @@ export class Service {
|
|
|
return await response.json();
|
|
|
}
|
|
|
|
|
|
- async post(body){
|
|
|
-
|
|
|
- let headers ={
|
|
|
-
|
|
|
- "Accept-Encoding" : "gzip, deflate, br",
|
|
|
- "accept": "*/*",
|
|
|
- "accept-language": "en-US,en;q=0.9,es;q=0.8",
|
|
|
- "cache-control": "no-cache",
|
|
|
- "content-type": "text/plain;charset=UTF-8",
|
|
|
- "pragma": "no-cache",
|
|
|
- "sec-gpc": "1",
|
|
|
- 'Accept': 'application/json',
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- // "Content-Length": body.Length
|
|
|
- }
|
|
|
-
|
|
|
- headers = {
|
|
|
- // 'Accept': '*/*',
|
|
|
- 'Accept': 'application/json',
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- "accept-language": "en-US,en;q=0.9,es;q=0.8",
|
|
|
- "cache-control": "no-cache",
|
|
|
- "pragma": "no-cache",
|
|
|
- "sec-gpc": "1"
|
|
|
- }
|
|
|
-
|
|
|
- let response = await fetch("http://psicoadmin.ditca.org:8081/registro", {
|
|
|
- // "headers": new Headers( headers ),
|
|
|
- "headers": new Headers( headers ),
|
|
|
- "referrer": "http://localhost:3000/",
|
|
|
- "referrerPolicy": "strict-origin-when-cross-origin",
|
|
|
- "body": JSON.stringify(body),
|
|
|
- "method": "POST",
|
|
|
- "mode": "cors",
|
|
|
- });
|
|
|
- console.log(response);
|
|
|
- return await response.json();
|
|
|
- }
|
|
|
}
|
|
|
|