我遵循此https://github.com/gethuman/nativescript-https
安装:tns plugin add nativescript-https
编写此代码:
public output() {
Https.request({
url: 'https://xxx.xxx.x.x/output?pass=1&out1=1',
method: 'GET',
headers: {
'Authorization': 'Basic ZWx1c3VhcmlvOnlsYWNsYXZl',
'x-uuid': 'aHR0cHdhdGNoOmY',
'x-version': '4.2.0',
'x-env': 'DEVELOPMENT',
},
}).then(function(response) {
console.log('Https.request response', response)
}).catch(function(error) {
console.error('Https.request error', error)
})
}
命令:tns run
显示这个:
JS: nativescript-https > Disabled SSL pinning by default
JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: Https.request error ReferenceError: okhttp3 is not defined