Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
为了可以降低回调深度,并且能够更好的集成async和await。请求返回的结果是Promise。
注意headers选项使用小写,尤其是content-type等常用字段,因为在代码内部使用了小写的方式传递。
const awyhttp = require('awyhttp');
awyhttp.get('http://localhost:2021/')
.then(data => {
console.log(data);
}, err => {
console.log(err);
}).catch(err => {
console.log(err);
});
awyhttp.post('http://localhost:2021/pt', {
data : {
name : 'Albert Einstein',
identity : 'physics'
}
})
.then(data => {
console.log(data);
}, err => {
console.log(err);
});
awyhttp.upload('http://localhost:2021/upload2', {
file : '/home/wy/tmp/fengye.jpg',
upload_name : 'image'
})
.then(data => {
console.log(data);
}, err => {
console.log(err);
});
var img_url = 'https://api.w3xm.top/media/images/u/u195f09b89a97fe441699debbe2b4600f21027072.png';
awyhttp.download(img_url, {
method : 'GET',
target : '/tmp/dtest.png'
}).then(data => {
console.log(data);
}, err => {
console.log(err);
}).catch(err => {
console.log(err);
});
var put_data = "Unix's name is not Unix";
//要在async声明的函数中使用
var r = await awyhttp.put(url, {
data : put_data
headers : {
'content-type' : 'text/plain'
}
});
//注意要在async声明的函数中使用
var r = await awyhttp.delete(url);
FAQs
small,simple http client
We found that awyhttp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.