Call wifiManager.getIpInfo() of the wifiManager module to obtain ipInfo and convert it into a common IP address format. Note that the ohos.permission.GET_WIFI_INFO permission is required for calling this API.
The sample code is as follows:
import { wifiManager } from '@kit.ConnectivityKit';
let ipAddress = wifiManager.getIpInfo().ipAddress;
let ip = (ipAddress >>> 24) + "." + (ipAddress >> 16 & 0xFF) + "." + (ipAddress >> 8 & 0xFF) + "." + (ipAddress & 0xFF);