
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@wisdomgarden/cloak-plugin-http
Advanced tools
Making native HTTP requests within Cloak applications.
CloakPluginHttp 是 Cloak 框架的插件之一,用于在 Cloak 应用中进行 HTTP 请求。
安装 Cloak 框架
@wisdomgarden/cloak具体细节参考 @wisdomgarden/cloak
安装 CloakPluginHttp 插件
ohpm install @wisdomgarden/cloak-plugin-http
npm install @wisdomgarden/cloak-plugin-http # optional
在项目 entry/src/main/module.json5 中声明网络访问权限。
示例:
"requestPermissions": [
// ...
{
"name": "ohos.permission.INTERNET",
"reason": "$string:permission_internet_reason",
"usedScene": {
"abilities": [
"EntryAbility"
],
"when": "inuse"
}
},
// ...
]
在 H5 逻辑代码中就可以直接调用该插件
如果你使用 Typescript 或者想在前端扩展插件,安装 NPM 包
npm install @wisdomgarden/cloak-plugin-http
const httpGet = async () => {
const url = "https://api.restful-api.dev/objects";
const response = await Cloak.plugins.Http.sendRequest(url);
alert(JSON.stringify(response.data, null , 2));
};
const httpPost = async () => {
const url = "https://api.restful-api.dev/objects";
const response = await Cloak.plugins.Http.sendRequest(url, {
method: "post",
headers: {
"Content-Type": "application/json",
},
data: {
username: "account",
password: "password",
},
});
alert(JSON.stringify(response.data, null , 2));
};
export interface HttpPlugin extends Plugin {
sendRequest(url: string, options?: RequestOptions): Promise<HTTPResponse>;
}
interface HTTPResponse {
status: number;
headers: { [key: string]: string };
url: string;
data?: ESObject;
error?: ESObject;
}
interface HTTPResponse {
status: number;
headers: { [key: string]: string };
url: string;
data?: ESObject;
error?: ESObject;
}
Cloak 是专为 HarmonyOS 设计的混合开发框架,类似 Cordova 和 Capacitor,但具备 更轻量、更高性能 的特性。
该框架可将 Web 应用快速转换为原生应用,同时通过插件机制访问 HarmonyOS 原生能力。
更多关于 Cloak 框架信息,请查看: https://github.com/WisdomGardenInc/Cloak
FAQs
Making native HTTP requests within Cloak applications.
We found that @wisdomgarden/cloak-plugin-http demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.