Browse Source

network type fetch

amenpunk 3 years ago
parent
commit
64c23cdb27
3 changed files with 45 additions and 3 deletions
  1. 42 0
      src/Pages/Contras.jsx
  2. 2 2
      src/Pages/Login.jsx
  3. 1 1
      src/Utils/HTTP.js

+ 42 - 0
src/Pages/Contras.jsx

1
+import $ from 'jquery'  
2
+import { Button, Col , Row } from 'react-bootstrap'
3
+import { HTTP_ } from '../Utils/HTTP'
4
+
1
 export function Contras() {
5
 export function Contras() {
6
+
7
+
8
+    const QueryV1 = async () => {
9
+         await $.post('http://psicoadmin.ditca.org:8081/user?user=patrik&password=12345');
10
+    }
11
+    
12
+    const FetchV2 = async () => {
13
+        await fetch('http://psicoadmin.ditca.org:8081/user?user=patrik&password=12345', { method : 'POST' });
14
+    }
15
+
16
+    const HTTPV3  =  async () => {
17
+        let htp = new HTTP_()
18
+        await htp.get_()
19
+    }
20
+
21
+
22
+
2
     return (
23
     return (
3
         <div className="content-section">
24
         <div className="content-section">
4
             <div className="main">
25
             <div className="main">
5
                 <h1>Passwords</h1>
26
                 <h1>Passwords</h1>
27
+
28
+                    <Row>
29
+                        <Col>
30
+                            <Button onClick={QueryV1}> Request tipo 1 </Button>
31
+                        </Col>
32
+                    </Row>
33
+                    <hr/>
34
+                    
35
+                    <Row>
36
+                        <Col>
37
+                            <Button onClick={FetchV2}> Request tipo 2 </Button>
38
+                        </Col>
39
+                    </Row>
40
+                    <hr/>
41
+                    
42
+                    <Row>
43
+                        <Col>
44
+                            <Button onClick={HTTPV3}>Request tipo 3</Button>
45
+                        </Col>
46
+                    </Row>
47
+
6
             </div>
48
             </div>
7
         </div>
49
         </div>
8
     )
50
     )

+ 2 - 2
src/Pages/Login.jsx

18
 import { useFormik } from 'formik';
18
 import { useFormik } from 'formik';
19
 import * as Yup from 'yup';
19
 import * as Yup from 'yup';
20
 
20
 
21
-import { HTTP } from '../Utils/HTTP.js'
21
+import { HTTP_ } from '../Utils/HTTP.js'
22
 
22
 
23
 const LoginSchema = Yup.object().shape({
23
 const LoginSchema = Yup.object().shape({
24
     email : Yup
24
     email : Yup
49
             let { email, password } = values
49
             let { email, password } = values
50
             console.log(email,password);
50
             console.log(email,password);
51
             // let request = new HTTP('/user?' + `user=${email}&password=${password}`)
51
             // let request = new HTTP('/user?' + `user=${email}&password=${password}`)
52
-            let request = new HTTP()
52
+            let request = new HTTP_()
53
             request.get_()
53
             request.get_()
54
             // toast.success('Bienvenido!!')
54
             // toast.success('Bienvenido!!')
55
             // toast.error("This didn't work.")
55
             // toast.error("This didn't work.")

+ 1 - 1
src/Utils/HTTP.js

1
 // import axios from 'axios';
1
 // import axios from 'axios';
2
 import $ from "jquery" 
2
 import $ from "jquery" 
3
 
3
 
4
-export class HTTP {
4
+export class HTTP_ {
5
 
5
 
6
     constructor(url){
6
     constructor(url){
7
         this.base_url = 'http://204.48.25.93:8081/users'; 
7
         this.base_url = 'http://204.48.25.93:8081/users';