simple ajax library
1.0.0
Загрузите и включите файл JavaScript | полная версия | уменьшенный | Версия ES6 |
< script src =" simpleAjax.js " > </ script >
< script src =" simpleAjax.min.js " > </ script >
Создайте новый простой Ajax
const http = new simpleAJAX ;
users = http . get ( 'https://jsonplaceholder.typicode.com/users' ,
( err , users ) => {
if ( err ) {
console . log ( err )
} else {
console . log ( users ) ;
}
} ) ;
const data = {
"name" : "Bolaji Ayodeji" ,
"username" : "bolajiayodeji" ,
"email" : "[email protected]" ,
"address" : {
"street" : "Hello world" ,
"suite" : "Hello" ,
"city" : "Lokoja, Kogi" ,
"zipcode" : "xxx-xxx-xxx" ,
"geo" : {
"lat" : "29.4572" ,
"lng" : "-164.2990"
}
} ,
"phone" : "+234 8109445504" ,
"website" : "https://bolajiayodeji.com" ,
"company" : {
"name" : "PhilanthroLab" ,
"catchPhrase" : "Multi-tiered zero tolerance productivity" ,
"bs" : "transition cutting-edge web services"
}
} ;
http . post ( 'https://jsonplaceholder.typicode.com/users' ,
data , ( err , user ) => {
if ( err ) {
console . log ( err )
} else {
console . log ( user ) ;
}
} ) ;
const data = {
"name" : "Bolaji Ayodeji" ,
"username" : "bolajiayodeji" ,
"email" : "[email protected]" ,
"address" : {
"street" : "Hello world" ,
"suite" : "Hello" ,
"city" : "Lokoja, Kogi" ,
"zipcode" : "xxx-xxx-xxx" ,
"geo" : {
"lat" : "29.4572" ,
"lng" : "-164.2990"
}
} ,
"phone" : "+234 8109445504" ,
"website" : "https://bolajiayodeji.com" ,
"company" : {
"name" : "PhilanthroLab" ,
"catchPhrase" : "Multi-tiered zero tolerance productivity" ,
"bs" : "transition cutting-edge web services"
}
} ;
http . put ( 'https://jsonplaceholder.typicode.com/users/1' ,
data , ( err , user ) => {
if ( err ) {
console . log ( err )
} else {
console . log ( user ) ;
}
} ) ;
users = http . delete ( 'https://jsonplaceholder.typicode.com/users/1' ,
( err , response ) => {
if ( err ) {
console . log ( err )
} else {
console . log ( response ) ;
}
} ) ;
Демо здесь
git clone https://github.com/BolajiAyodeji/simple-ajax-library.git
cd simple-ajax-library
npm install
npm run build