首页 > 解决方案 > JS: Https.request 错误 ReferenceError: okhttp3 is not defined

问题描述

我按照这个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

标签: angularhttpsnativescript

解决方案


推荐阅读