Advertisement
Raditio_123

view/login

Apr 26th, 2022
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <div>
  2.           <button onclick="post()">post</button>
  3.           <button onclick="postAxios()">post axios</button>
  4.         </div>
  5.        
  6.     <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  7.       <script>
  8.  
  9.         const post = () => {
  10.             let data = {
  11.                 email : 'db@gmail.ss',
  12.                 password:'123456'
  13.             }
  14.             fetch('http://kisglob.test/login',{
  15.                 method: 'POST',
  16.                 headers: {
  17.                     'Content-Type': 'application/json'
  18.                     // 'Content-Type': 'application/x-www-form-urlencoded',
  19.                 },
  20.                 body: JSON.stringify(data)
  21.             })
  22.         .then(response => response.json())
  23.         .then(data => console.log(data));
  24.         }
  25.  
  26.         const postAxios = () => {
  27.             axios.post('http://kisglob.test/login', {
  28.                 email : 'db@gmail.ss',
  29.                 password:'123456'
  30.             })
  31.             .then(function (response) {
  32.                 console.log(response);
  33.             })
  34.             .catch(function (error) {
  35.                 console.log(error);
  36.             });
  37.         }
  38.  
  39.         document.addEventListener("DOMContentLoaded", function(event) {
  40.  
  41.             // Your code to run since DOM is loaded and ready
  42.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement