网络判断
This commit is contained in:
parent
37f135744f
commit
23e115e89e
@ -4,6 +4,7 @@ import prompt from '@ohos.prompt';
|
||||
import { tcpUtil } from './TcpRequest';
|
||||
import Prompt from '@system.prompt';
|
||||
import tempRequest from './tempRequest';
|
||||
import connection from '@ohos.net.connection';
|
||||
|
||||
export function tcpRequest<T>(req: any): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -96,6 +97,14 @@ export default async function request<T>(req: any): Promise<T> {
|
||||
resolve(response as T)
|
||||
}).catch(err => {
|
||||
console.log("[http request] only http request error")
|
||||
connection.getDefaultNet().then(handle => {
|
||||
console.log("[http request] network handle", JSON.stringify(handle))
|
||||
connection.getNetCapabilities(handle).then(res => {
|
||||
console.log("[http request] network result", JSON.stringify(res))
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log("[http request] network error", JSON.stringify(err))
|
||||
})
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user