Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
310fcd38
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
310fcd38
编写于
3月 01, 2023
作者:
Y
Yangys
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update ErrorCode Monthly
Signed-off-by:
N
Yangys
<
yangyousheng@huawei.com
>
上级
db112bcc
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
5030 addition
and
467 deletion
+5030
-467
zh-cn/application-dev/connectivity/http-request.md
zh-cn/application-dev/connectivity/http-request.md
+35
-19
zh-cn/application-dev/reference/apis/js-apis-http.md
zh-cn/application-dev/reference/apis/js-apis-http.md
+464
-33
zh-cn/application-dev/reference/apis/js-apis-net-connection.md
.../application-dev/reference/apis/js-apis-net-connection.md
+989
-299
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
+150
-52
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
+1558
-0
zh-cn/application-dev/reference/apis/js-apis-net-sharing.md
zh-cn/application-dev/reference/apis/js-apis-net-sharing.md
+271
-27
zh-cn/application-dev/reference/apis/js-apis-socket.md
zh-cn/application-dev/reference/apis/js-apis-socket.md
+165
-24
zh-cn/application-dev/reference/apis/js-apis-system-fetch.md
zh-cn/application-dev/reference/apis/js-apis-system-fetch.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-system-network.md
.../application-dev/reference/apis/js-apis-system-network.md
+7
-5
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
+54
-3
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
+6
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md
...tion-dev/reference/errorcodes/errorcode-net-connection.md
+114
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md
...cation-dev/reference/errorcodes/errorcode-net-ethernet.md
+116
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md
...pplication-dev/reference/errorcodes/errorcode-net-http.md
+527
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md
...lication-dev/reference/errorcodes/errorcode-net-policy.md
+59
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md
...ication-dev/reference/errorcodes/errorcode-net-sharing.md
+159
-0
zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md
...lication-dev/reference/errorcodes/errorcode-net-socket.md
+351
-0
zh-cn/readme/网络管理子系统.md
zh-cn/readme/网络管理子系统.md
+0
-0
未找到文件。
zh-cn/application-dev/connectivity/http-request.md
浏览文件 @
310fcd38
...
...
@@ -18,32 +18,41 @@ HTTP数据请求功能主要由http模块提供。
| ----------------------------------------- | ----------------------------------- |
| createHttp() | 创建一个http请求。 |
| request() | 根据URL地址,发起HTTP网络请求。 |
| request2()
<sup>
10+
</sup>
| 根据URL地址,发起HTTP网络请求并返回流式响应|
| destroy() | 中断请求任务。 |
| on(type: 'headersReceive') | 订阅HTTP Response Header 事件。 |
| off(type: 'headersReceive') | 取消订阅HTTP Response Header 事件。 |
| once
\(
'headersReceive'
\)
<sup>
8+
</sup>
| 订阅HTTP Response Header 事件,但是只触发一次。|
| on
\(
'dataReceive'
\)
<sup>
10+
</sup>
| 订阅HTTP流式响应数据接收事件。 |
| off
\(
'dataReceive'
\)
<sup>
10+
</sup>
| 取消订阅HTTP流式响应数据接收事件。 |
| on
\(
'dataEnd'
\)
<sup>
10+
</sup>
| 订阅HTTP流式响应数据接收完毕事件。 |
| off
\(
'dataEnd'
\)
<sup>
10+
</sup>
| 取消订阅HTTP流式响应数据接收完毕事件。 |
| on
\(
'dataProgress'
\)
<sup>
10+
</sup>
| 订阅HTTP流式响应数据接收进度事件。 |
| off
\(
'dataProgress'
\)
<sup>
10+
</sup>
| 取消订阅HTTP流式响应数据接收进度事件。 |
## 开发步骤
1.
import需要的http模块。
2.
创建一个HTTP请求,返回一个HttpRequest对象。
3.
(可选)订阅HTTP响应头。
4.
根据URL地址,发起HTTP网络请求。
5.
(可选)处理HTTP响应头和HTTP网络请求的返回结果。
1.
从@ohos.net.http.d.ts中导入http命名空间。
2.
调用createHttp()方法,创建一个HttpRequest对象。
3.
调用该对象的on()方法,订阅http响应头事件,此接口会比request请求先返回。可以根据业务需要订阅此消息。
4.
调用该对象的request()方法,传入http请求的url地址和可选参数,发起网络请求。
5.
按照实际业务需要,解析返回结果。
6.
调用该对象的off()方法,取消订阅http响应头事件。
7.
当该请求使用完毕时,调用destroy()方法主动销毁。
```
js
// 引入包名
import
http
from
'
@ohos.net.http
'
;
// 每一个httpRequest对应一个
http
请求任务,不可复用
// 每一个httpRequest对应一个
HTTP
请求任务,不可复用
let
httpRequest
=
http
.
createHttp
();
// 用于订阅http响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息
// 用于订阅HTTP响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息
// 从API 8开始,使用on('headersReceive', Callback)替代on('headerReceive', AsyncCallback)。 8+
httpRequest
.
on
(
'
headersReceive
'
,
(
header
)
=>
{
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
header
));
});
httpRequest
.
request
(
// 填写
http请求的url
地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
// 填写
HTTP请求的URL
地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定
"
EXAMPLE_URL
"
,
{
method
:
http
.
RequestMethod
.
POST
,
// 可选,默认为http.RequestMethod.GET
...
...
@@ -55,19 +64,26 @@ httpRequest.request(
extraData
:
{
"
data
"
:
"
data to send
"
,
},
connectTimeout
:
60000
,
// 可选,默认为60s
readTimeout
:
60000
,
// 可选,默认为60s
expectDataType
:
http
.
HttpDataType
.
STRING
,
// 可选,指定返回数据的类型
usingCache
:
true
,
// 可选,默认为true
priority
:
1
,
// 可选,默认为1
connectTimeout
:
60000
,
// 可选,默认为60000ms
readTimeout
:
60000
,
// 可选,默认为60000ms
usingProtocol
:
http
.
HttpProtocol
.
HTTP1_1
,
// 可选,协议类型默认值由系统自动指定
usingProxy
:
false
,
//可选,默认不使用网络代理,自API 10开始支持该属性
},
(
err
,
data
)
=>
{
if
(
!
err
)
{
// data.result为
http
响应内容,可根据业务需要进行解析
console
.
info
(
'
Result:
'
+
data
.
result
);
console
.
info
(
'
code:
'
+
data
.
responseCode
);
// data.header为
http
响应头,可根据业务需要进行解析
// data.result为
HTTP
响应内容,可根据业务需要进行解析
console
.
info
(
'
Result:
'
+
JSON
.
stringify
(
data
.
result
)
);
console
.
info
(
'
code:
'
+
JSON
.
stringify
(
data
.
responseCode
)
);
// data.header为
HTTP
响应头,可根据业务需要进行解析
console
.
info
(
'
header:
'
+
JSON
.
stringify
(
data
.
header
));
console
.
info
(
'
cookies:
'
+
data
.
cookies
);
// 8+
console
.
info
(
'
cookies:
'
+
JSON
.
stringify
(
data
.
cookies
)
);
// 8+
}
else
{
console
.
info
(
'
error:
'
+
JSON
.
stringify
(
err
));
// 该请求不再使用,调用destroy方法主动销毁。
// 取消订阅HTTP响应头事件
httpRequest
.
off
(
'
headersReceive
'
);
// 当该请求使用完毕时,调用destroy方法主动销毁。
httpRequest
.
destroy
();
}
}
...
...
@@ -76,5 +92,5 @@ httpRequest.request(
## 相关实例
针对HTTP数据请求,有以下相关实例可供参考:
-
[
`Http:`数据请求(ArkTS)(API9))
](
https://gitee.com/openharmony/applications_app_samples/tree/m
onthly_20221018/Network
/Http
)
-
[
`Http:`数据请求(ArkTS)(API9))
](
https://gitee.com/openharmony/applications_app_samples/tree/m
aster/code/BasicFeature/Connectivity
/Http
)
-
[
使用HTTP实现与服务端通信(ArkTS)(API9)
](
https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH
)
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-http.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-net-connection.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
浏览文件 @
310fcd38
...
...
@@ -3,7 +3,6 @@
以太网连接管理主要提供有线网络能力,提供设置有线网络的IP地址,子网掩码,网关,DNS等信息
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
...
...
@@ -32,18 +31,37 @@ setIfaceConfig(iface: string, ic: InterfaceConfiguration, callback: AsyncCallbac
| ic |
[
InterfaceConfiguration
](
#interfaceconfiguration
)
| 是 | 要设置的网络接口配置信息 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数,成功无返回,失败返回对应错误码。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
| 2201006 | Device disconnected. |
| 2201007 | Failed to write the user configuration. |
**示例:**
```
js
ethernet
.
setIfaceConfig
(
"
eth0
"
,
{
mode
:
ethernet
.
STATIC
,
ipAddr
:
"
192.168.1.123
"
,
routeAddr
:
"
192.168.1.1
"
,
gateAddr
:
"
192.168.1.1
"
,
maskAddr
:
"
255.255.255.0
"
,
dnsAddr0
:
"
1.1.1.1
"
,
dnsAddr1
:
"
2.2.2.2
"
},
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
setIfaceConfig callback error =
"
+
error
);
}
else
{
console
.
log
(
"
setIfaceConfig callback ok
"
);
}
});
ethernet
.
setIfaceConfig
(
"
eth0
"
,
{
mode
:
0
,
ipAddr
:
"
192.168.xx.xxx
"
,
route
:
"
192.168.xx.xxx
"
,
gateway
:
"
192.168.xx.xxx
"
,
netMask
:
"
255.255.255.0
"
,
dnsServers
:
"
1.1.1.1
"
,
domain
:
"
2.2.2.2
"
},
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
setIfaceConfig callback error =
"
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
"
setIfaceConfig callback ok
"
);
}
});
```
## ethernet.setIfaceConfig
...
...
@@ -71,14 +89,34 @@ setIfaceConfig(iface: string, ic: InterfaceConfiguration): Promise\<void>
| ------------------- | ----------------------------------------------------------- |
| Promise
\<
void> | 以Promise形式返回执行结果。成功无返回,失败返回对应错误码。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
| 2201006 | Device disconnected. |
| 2201007 | Failed to write the user configuration. |
**示例:**
```
js
ethernet
.
setIfaceConfig
(
"
eth0
"
,
{
mode
:
ethernet
.
STATIC
,
ipAddr
:
"
192.168.1.123
"
,
routeAddr
:
"
192.168.1.1
"
,
gateAddr
:
"
192.168.1.1
"
,
maskAddr
:
"
255.255.255.0
"
,
dnsAddr0
:
"
1.1.1.1
"
,
dnsAddr1
:
"
2.2.2.2
"
}).
then
(()
=>
{
ethernet
.
setIfaceConfig
(
"
eth0
"
,
{
mode
:
0
,
ipAddr
:
"
192.168.xx.xxx
"
,
route
:
"
192.168.xx.xxx
"
,
gateway
:
"
192.168.xx.xxx
"
,
netMask
:
"
255.255.255.0
"
,
dnsServers
:
"
1.1.1.1
"
,
domain
:
"
2.2.2.2
"
}).
then
(()
=>
{
console
.
log
(
"
setIfaceConfig promiss ok
"
);
}).
catch
(
(
error
)
=>
{
console
.
log
(
"
setIfaceConfig promiss error =
"
+
error
);
}).
catch
(
error
=>
{
console
.
log
(
"
setIfaceConfig promiss error =
"
+
JSON
.
stringify
(
error
)
);
});
```
...
...
@@ -101,20 +139,31 @@ getIfaceConfig(iface: string, callback: AsyncCallback\<InterfaceConfiguration>):
| iface | string | 是 | 指定网络接口 |
| callback | AsyncCallback
\<
[
InterfaceConfiguration
](
#interfaceconfiguration
)
> | 是 | 回调函数,返回指定网络接口信息 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
**示例:**
```
js
ethernet
.
getIfaceConfig
(
"
eth0
"
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
log
(
"
getIfaceConfig callback error =
"
+
error
);
console
.
log
(
"
getIfaceConfig callback error =
"
+
JSON
.
stringify
(
error
)
);
}
else
{
console
.
log
(
"
getIfaceConfig callback mode =
"
+
value
.
mode
);
console
.
log
(
"
getIfaceConfig callback ipAddr =
"
+
value
.
ipAddr
);
console
.
log
(
"
getIfaceConfig callback route
Addr =
"
+
value
.
routeAddr
);
console
.
log
(
"
getIfaceConfig callback gate
Addr =
"
+
value
.
gateAddr
);
console
.
log
(
"
getIfaceConfig callback
maskAddr =
"
+
value
.
maskAddr
);
console
.
log
(
"
getIfaceConfig callback dns
0Addr =
"
+
value
.
dns0Addr
);
console
.
log
(
"
getIfaceConfig callback d
ns1Addr =
"
+
value
.
dns1Addr
);
console
.
log
(
"
getIfaceConfig callback mode =
"
+
JSON
.
stringify
(
value
.
mode
)
);
console
.
log
(
"
getIfaceConfig callback ipAddr =
"
+
JSON
.
stringify
(
value
.
ipAddr
)
);
console
.
log
(
"
getIfaceConfig callback route
=
"
+
JSON
.
stringify
(
value
.
route
)
);
console
.
log
(
"
getIfaceConfig callback gate
way =
"
+
JSON
.
stringify
(
value
.
gateway
)
);
console
.
log
(
"
getIfaceConfig callback
netMask =
"
+
JSON
.
stringify
(
value
.
netMask
)
);
console
.
log
(
"
getIfaceConfig callback dns
Servers =
"
+
JSON
.
stringify
(
value
.
dnsServers
)
);
console
.
log
(
"
getIfaceConfig callback d
omain =
"
+
JSON
.
stringify
(
value
.
domain
)
);
}
});
```
...
...
@@ -143,19 +192,30 @@ getIfaceConfig(iface: string): Promise\<InterfaceConfiguration>
| --------------------------------- | ---------------------------------- |
| Promise
\<
[
InterfaceConfiguration
](
#interfaceconfiguration
)
> | 以Promise形式返回接口信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
**示例:**
```
js
ethernet
.
getIfaceConfig
(
"
eth0
"
).
then
((
data
)
=>
{
console
.
log
(
"
getIfaceConfig promiss mode =
"
+
data
.
mode
);
console
.
log
(
"
getIfaceConfig promiss ipAddr =
"
+
data
.
ipAddr
);
console
.
log
(
"
getIfaceConfig promiss route
Addr =
"
+
data
.
routeAddr
);
console
.
log
(
"
getIfaceConfig promiss gate
Addr =
"
+
data
.
gateAddr
);
console
.
log
(
"
getIfaceConfig promiss
maskAddr =
"
+
data
.
maskAddr
);
console
.
log
(
"
getIfaceConfig promiss dns
0Addr =
"
+
data
.
dns0Addr
);
console
.
log
(
"
getIfaceConfig promiss d
ns1Addr =
"
+
data
.
dns1Addr
);
}).
catch
(
(
error
)
=>
{
console
.
log
(
"
getIfaceConfig promiss error =
"
+
error
);
console
.
log
(
"
getIfaceConfig promiss mode =
"
+
JSON
.
stringify
(
data
.
mode
)
);
console
.
log
(
"
getIfaceConfig promiss ipAddr =
"
+
JSON
.
stringify
(
data
.
ipAddr
)
);
console
.
log
(
"
getIfaceConfig promiss route
=
"
+
JSON
.
stringify
(
data
.
route
)
);
console
.
log
(
"
getIfaceConfig promiss gate
way =
"
+
JSON
.
stringify
(
data
.
gateway
)
);
console
.
log
(
"
getIfaceConfig promiss
netMask =
"
+
JSON
.
stringify
(
data
.
netMask
)
);
console
.
log
(
"
getIfaceConfig promiss dns
Servers =
"
+
JSON
.
stringify
(
data
.
dnsServers
)
);
console
.
log
(
"
getIfaceConfig promiss d
omain =
"
+
JSON
.
stringify
(
data
.
domain
)
);
}).
catch
(
error
=>
{
console
.
log
(
"
getIfaceConfig promiss error =
"
+
JSON
.
stringify
(
error
)
);
});
```
...
...
@@ -178,15 +238,26 @@ isIfaceActive(iface: string, callback: AsyncCallback\<number>): void
| iface | string | 是 | 接口名。为空时代表查询是否存在激活接口 |
| callback | AsyncCallback
\<
number> | 是 | 回调函数,已激活:1,未激活:0,其他为获取失败错误码。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
**示例:**
```
js
ethernet
.
isIfaceActive
(
"
eth0
"
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
log
(
"
whether2Activate callback error =
"
+
error
);
}
else
{
console
.
log
(
"
whether2Activate callback =
"
+
value
);
}
if
(
error
)
{
console
.
log
(
"
whether2Activate callback error =
"
+
JSON
.
stringify
(
error
)
);
}
else
{
console
.
log
(
"
whether2Activate callback =
"
+
JSON
.
stringify
(
value
)
);
}
});
```
...
...
@@ -214,13 +285,24 @@ isIfaceActive(iface: string): Promise\<number>
| ----------------| ------------------------------------------------------------------ |
| Promise
\<
number> | 以Promise形式返回获取结果。已激活:1,未激活:0,其他为获取失败错误码。|
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 401 | Parameter error. |
| 2200001 | Invalid parameter value. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
| 2201005 | The device information does not exist. |
**示例:**
```
js
ethernet
.
isIfaceActive
(
"
eth0
"
).
then
((
data
)
=>
{
console
.
log
(
"
isIfaceActive promiss =
"
+
data
);
}).
catch
(
(
error
)
=>
{
console
.
log
(
"
isIfaceActive promiss error =
"
+
error
);
console
.
log
(
"
isIfaceActive promiss =
"
+
JSON
.
stringify
(
data
)
);
}).
catch
(
error
=>
{
console
.
log
(
"
isIfaceActive promiss error =
"
+
JSON
.
stringify
(
error
)
);
});
```
...
...
@@ -242,18 +324,26 @@ getAllActiveIfaces(callback: AsyncCallback\<Array\<string>>): void
| -------- | ------------------------------------ | ---- | ------------------------------ |
| callback | AsyncCallback
\<
Array
\<
string>> | 是 | 回调函数,返回值为对应接口名。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
**示例:**
```
js
ethernet
.
getAllActiveIfaces
((
error
,
value
)
=>
{
if
(
error
)
{
console
.
log
(
"
getAllActiveIfaces callback error =
"
+
error
);
}
else
{
console
.
log
(
"
getAllActiveIfaces callback value.length =
"
+
value
.
length
);
for
(
let
i
=
0
;
i
<
value
.
length
;
i
++
)
{
console
.
log
(
"
getAllActiveIfaces callback =
"
+
value
[
i
]);
if
(
error
)
{
console
.
log
(
"
getAllActiveIfaces callback error =
"
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
"
getAllActiveIfaces callback value.length =
"
+
JSON
.
stringify
(
value
.
length
));
for
(
let
i
=
0
;
i
<
value
.
length
;
i
++
)
{
console
.
log
(
"
getAllActiveIfaces callback =
"
+
JSON
.
stringify
(
value
[
i
]));
}
}
}
});
```
...
...
@@ -275,16 +365,24 @@ getAllActiveIfaces(): Promise\<Array\<string>>
| ------------------------------ | ----------------------------------------------- |
| Promise
\<
Array
\<
string>> | 以Promise形式返回获取结果。返回值为对应接口名。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | ----------------------------------------|
| 201 | Permission denied. |
| 2200002 | Operation failed. Cannot connect to service.|
| 2200003 | System internal error. |
**示例:**
```
js
ethernet
.
getAllActiveIfaces
().
then
((
data
)
=>
{
console
.
log
(
"
getAllActiveIfaces promiss data.length =
"
+
data
.
length
);
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
log
(
"
getAllActiveIfaces promiss =
"
+
data
[
i
]
);
}
}).
catch
(
(
error
)
=>
{
console
.
log
(
"
getAllActiveIfaces promiss error =
"
+
error
);
console
.
log
(
"
getAllActiveIfaces promiss data.length =
"
+
JSON
.
stringify
(
data
.
length
)
);
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
console
.
log
(
"
getAllActiveIfaces promiss =
"
+
JSON
.
stringify
(
data
[
i
])
);
}
}).
catch
(
error
=>
{
console
.
log
(
"
getAllActiveIfaces promiss error =
"
+
JSON
.
stringify
(
error
)
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-net-sharing.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-socket.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-system-fetch.md
浏览文件 @
310fcd38
...
...
@@ -45,11 +45,11 @@ fetch(Object): void
## FetchResponse
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| code | number | 表示服务器的状态code。 |
| data | string
\|
Object | 返回数据类型由responseType确定,详见表 responseType与success中data关系。 |
| headers | Object | 表示服务器response的所有header。 |
| 参数名 | 类型 |
可读 | 可写 |
说明 |
| -------- | -------- | -------- |
-------- | -------- |
| code | number |
是 | 否 |
表示服务器的状态code。 |
| data | string
\|
Object |
是 | 否 |
返回数据类型由responseType确定,详见表 responseType与success中data关系。 |
| headers | Object |
是 | 否 |
表示服务器response的所有header。 |
**表2**
responseType与success中data关系
...
...
zh-cn/application-dev/reference/apis/js-apis-system-network.md
浏览文件 @
310fcd38
...
...
@@ -2,7 +2,7 @@
> **说明:**
> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.telephony.observer`](js-apis-observer.md)。
>
>
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
...
@@ -122,7 +122,9 @@ export default {
## NetworkResponse
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| metered | boolean | 是否按照流量计费。 |
| type | string | 网络类型,可能的值有2g,3g,4g,5g,wifi,none等。 |
\ No newline at end of file
**系统能力:**
SystemCapability.Communication.NetManager.Core
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| metered | boolean | 否 |是否按照流量计费。 |
| type | string | 是|网络类型,可能的值有2g,3g,4g,5g,wifi,none等。 |
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-webSocket.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/Readme-CN.md
浏览文件 @
310fcd38
...
...
@@ -49,6 +49,12 @@
-
[
电话子系统错误码
](
errorcode-telephony.md
)
-
网络管理
-
[
上传下载错误码
](
errorcode-request.md
)
-
[
HTTP错误码
](
errorcode-net-http.md
)
-
[
Socket错误码
](
errorcode-net-socket.md
)
-
[
网络连接管理错误码
](
errorcode-net-connection.md
)
-
[
以太网连接错误码
](
errorcode-net-ethernet.md
)
-
[
网络共享错误码
](
errorcode-net-sharing.md
)
-
[
策略管理错误码
](
errorcode-net-policy.md
)
-
通信与连接
-
[
NFC错误码
](
errorcode-nfc.md
)
-
[
RPC错误码
](
errorcode-rpc.md
)
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-net-connection.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/errorcode-net-ethernet.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/errorcode-net-http.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/errorcode-net-policy.md
0 → 100644
浏览文件 @
310fcd38
# 策略管理错误码
## 2100001 非法参数值
**错误信息**
Invalid parameter value.
**错误描述**
非法参数值
**可能原因**
输入参数取值范围错误。
**处理步骤**
检查输入参数的取值范围是否正确。
## 2100002 连接服务失败
**错误信息**
Operation failed. Cannot connect to service.
**错误描述**
操作失败,连接系统服务发生异常。
**可能原因**
服务发生异常。
**处理步骤**
检查系统服务运行状态是否正常。
## 2100003 系统内部错误
**错误信息**
System internal error.
**错误描述**
系统内部错误。
**可能原因**
1.
内存异常。
2.
空指针。
**处理步骤**
1.
检查内存空间是否充足,清理内存后重试。
2.
系统异常,请稍后重试或重启设备。
zh-cn/application-dev/reference/errorcodes/errorcode-net-sharing.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/errorcodes/errorcode-net-socket.md
0 → 100644
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
zh-cn/readme/网络管理子系统.md
浏览文件 @
310fcd38
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录