在微信小程序開發的時候,寫了兩個API請求:
- 請求A:
//請求Awx.request({url: 'https://wx.baidu.com/api/wx/getBallByDate',method: 'POST',dataType: 'json',data: {date: that.data.curDate},header: {'content-type': 'application/json'},success: function(dt) {console.log(dt);}})
- 請求B:
//請求Bwx.request({url: 'https://wx.baidu.com/api/wx/getBallByDate',method: 'POST',dataType: 'json',data: {data: ballNumber,car: abc},header: {'content-type': 'application/json'},success: function(dt) {console.log(dt);}})
當執行編譯,預覽網絡訪問時,發現請求頭信息報錯:
Request Headers: Provisional headers are shown
當時搜了好多篇相關文章,都是在說服務器的SSL配置的問題,或者緩存加載的問題。
因為當時我在另一個標簽頁中單獨訪問過請求B,HTTPS下訪問是有結果返回的。但是在包含請求A后,就訪問報錯。
后來才發現是因為請求A的一個參數為空,導致后端接口異常,所以才會出現 “?Provisional headers are shown” 這個錯誤。
所以當出現這種錯誤提示后,需要將所有請求的參數和后端接口對比,確保請求能正常訪問。
一個接口的異常會導致所有的請求都出現問題。
這種錯誤,如果排除服務器SSL配置的問題,基本上都是前端請求服務器的程序報錯導致。
在此記下來提醒自己踩過的坑,也給碰到同樣問題的人提供一些思路。