GET https://easy-mock.com/mock/5b962af7e0d1a17c279c8870/iview/data/list/1/10 net::ERR_CERT_COMMON_NAME_INVALID
时间: 2024-01-19 09:02:47 浏览: 42
根据提供的引用内容,您遇到的问题是由于证书名称无效导致的。这通常是因为您访问的网站使用了无效或过期的SSL证书。为了解决这个问题,您可以尝试以下几种方法:
1. 忽略证书错误:您可以在请求中添加一个选项来忽略证书错误。在JavaScript中,您可以使用`fetch`函数的`credentials`选项来实现这一点。示例代码如下:
```javascript
fetch('https://easy-mock.com/mock/5baf7e0d1a17c279c8870/iview/data/list/1/10', {
credentials: 'omit',
})
.then(response => response.json())
.then(data => {
// 处理返回的数据
})
.catch(error => {
// 处理错误
});
```
2. 使用有效的证书:如果您有权限更改服务器配置,您可以尝试使用有效的SSL证书。您可以从受信任的证书颁发机构(CA)获取有效的SSL证书,并将其配置到您的服务器上。
3. 检查URL是否正确:请确保您访问的URL是正确的,并且没有拼写错误或其他错误。
相关问题
wx.request({ url: 'https://www.easy-mock.com/mock/5b1e17a0d4a14a3247a6cd6b/', success: (res) => { this.setData({ detail: res.data.data }) } }) 分析这段代码
这段代码是使用微信小程序的 API wx.request() 发送 HTTP 请求获取数据,并在请求成功后将数据渲染到页面中。具体来说,该请求的 URL 是 https://www.easy-mock.com/mock/5b1e17a0d4a14a3247a6cd6b/,该 URL 对应的是一个模拟接口,返回的是一个模拟的数据集合。当请求成功后,通过 success 回调函数将返回的数据设置到页面的 data 属性中的 detail 字段中,以便在页面中使用渲染出来。需要注意的是,该请求是异步请求,因此必须使用回调函数来处理请求的结果。
finish: function () { var that = this; wx.request({ url: "https://www.easy-mock.com/mock/596257bc9adc231f357c4664/restaurant/filter", method: "GET", success: function (res) { that.setData({ restaurant: res.dat
这是一个小程序中的一个函数,用于发送 HTTP 请求获取数据并更新页面。在这个例子中,函数首先获取了当前页面实例对象 this,并将其保存在变量 that 中,然后使用 wx.request 发送了一个 GET 请求,请求地址为 https://www.easy-mock.com/mock/596257bc9adc231f357c4664/restaurant/filter。请求成功后,服务器会返回一个响应对象,其中包含了请求的数据。在 success 回调函数中,通过调用 this.setData 方法来更新页面中名为 restaurant 的数据,将其设置为响应对象的 data 属性值。示例代码如下:
```javascript
Page({
data: {
restaurant: []
},
finish: function () {
var that = this;
wx.request({
url: "https://www.easy-mock.com/mock/596257bc9adc231f357c4664/restaurant/filter",
method: "GET",
success: function (res) {
that.setData({
restaurant: res.data
})
}
})
}
})
```
上面的代码中,定义了一个名为 restaurant 的数据对象,其中初始值为空数组。在 finish 函数中,通过调用 wx.request 方法发送了一个 GET 请求,请求成功后通过调用 this.setData 方法将响应对象的 data 属性值赋值给 restaurant 数据对象,从而更新页面中的数据。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)