1.0.0 • Published 5 years ago

widjax v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@ Widjax

GitHub repo size GitHub

Easy and simple requests and responses


<script src="widjax.js"></script>

# Making a request

widjax.request('https://reqres.in/api/users', (res) => {
   console.log(res)
})

If you want to store the request amount

let req = widjax.request('https://reqres.in/api/users')

req.then(res => { 
   console.log(res) 
})

# Getting data from the database

<?php

// => server.php

$connection = new PDO('mysql:host=localhost;dbname=widjax', 'root', '');

$stmt = $connection->prepare("SELECT * FROM users");
$stmt->execute();
$result = $stmt->fetchAll();

exit(json_encode($result));
// => script.js

widjax.request('server.php', (res) => {
    console.log(res)
})

# POST Method

widjax.push('https://reqres.in/api/users', {
    first_name: 'Ian',
    last_name: 'Patrick',
    job_title: 'Programmer'
}).then(data => {
    console.log(data)
})
1.0.0

5 years ago