getNetworkType
Lấy kiểu kết nối mạng hiện tại.
Parameters
Object object
Property | Type | Default | Required | Description | Minimum Version |
---|---|---|---|---|---|
success | function | Callback function khi gọi api thành công | |||
fail | function | Callback function khi gọi api thất bại |
Return Values
Promise<Object data>
Property | Type | Description | Minimum Version |
---|---|---|---|
networkType | string | Với các giá trị:
|
Sample Code
import api from 'zmp-sdk';
api.getNetworkType({
success: (data) => {
// xử lý khi gọi api thành công
const { networkType } = data;
},
fail: (error) => {
// xử lý khi gọi api thất bại
console.log(error);
}
});
// hoặc
const test = async () => {
try {
const { networkType } = await api.getNetworkType({});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};