Declare the permission to access the network in the reqPermissions block in the config.json file. For details, please refer to Permission Development Guidelines.
{
"module": {
"reqPermissions": [
{
"name": "ohos.permission.INTERNET",
"reason": "access internet",
"usedScene": {
"ability": [
"com.mycamera.MainAbility"
],
"when": "always"
}
}
]
}
}