Function Compute provides the ctx.httpclient object to make HTTP and HTTPS requests to any web service. No additional dependencies are required.
The following example shows how to request a web page.
module.exports = async ctx => {
const res = await ctx.httpclient.request('https://www.example.com/x/xxx.htm');
return {
html: res.status === 200 ? res.data : '',
};
};
The ctx.httpclient object is an instance of urllib.
该文章对您有帮助吗?