To provide a secure and reliable network environment for users and improve their trust and satisfaction, you have to configure the domain name of the target server. For details, see Configuring Server Domain Names.
During atomic service development, you can temporarily turn on Waive restrictions for services under development on HarmonyOS devices to skip the verification of the server domain name.
You can start a data request using has.request. Common HTTP methods include GET, POST, OPTIONS, HEAD, PUT, DELETE, TRACE, and CONNECT.
Before using this function, you need to configure the server domain name by referring to Configuring Server Domain Names.
has.request({
url: 'https://www.example.com', // Replace the example URL with the actual URL.
data: {
x: '',
y: ''
},
success(res) {
console.log(res.data);
}
}); has.connectSocket({
url: 'ws://www.example.com', // Replace the example URL with the actual URL.
header: {
'content-type': 'application/json'
},
protocols: ['protocol1']
});