Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- <button onclick="post()">post</button>
- <button onclick="postAxios()">post axios</button>
- </div>
- <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
- <script>
- const post = () => {
- let data = {
- email : 'db@gmail.ss',
- password:'123456'
- }
- fetch('http://kisglob.test/login',{
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- // 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body: JSON.stringify(data)
- })
- .then(response => response.json())
- .then(data => console.log(data));
- }
- const postAxios = () => {
- axios.post('http://kisglob.test/login', {
- email : 'db@gmail.ss',
- password:'123456'
- })
- .then(function (response) {
- console.log(response);
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- document.addEventListener("DOMContentLoaded", function(event) {
- // Your code to run since DOM is loaded and ready
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement