这是试图获取
的代码 fetch('https://maps.googleapis.com/maps/api/geocode/json?address=14.588693,121.028468&key=mykey')
.then((response) => response.json())
.then((responseJson) => {
console.log('ADDRESS GEOCODE is BACK!! => ' + JSON.stringify(responseJson));})
但它使俗语网络请求失败我已经添加了
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>googleapis.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
</dict>
</dict>
</dict>
这是我的info.plisthttps://pastebin.com/q314uvrp
控制台日志:
可能的未经治疗的承诺拒绝(ID:1(: TypeError:网络请求失败 TypeError:网络请求失败 请访问xmlhttprequest.xhr.onerror [as _onerror](blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-be9f-be5e744a70509:26971:18( 请访问XMLHTTPREQUEST.DISPATCHEVENT(BLOB:http://localhost:8081/55322FD4-9CF7-416D-BE9F-BE9F-BA5E74A70509:1997775:18( 请访问xmlhttprequest._this._onerror(blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-be9f-be5e74a70509:199416:15( 在TryCallone(Blob:http://localhost:8081/55322FD4-9CF7-416D-BE9F-BA5E74A70509:3156:14( 在Blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-ba5e74a70509:3257:17 在blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-ba5e74a70509:27873:21 在_calltimer(blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-ba5e74a70509:27762:9( 在_callimmediatespass(blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-ba5e74a74a70509:27798:9( 在object.callimmediates(blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-ba5e74a74a70509:28017:14( 在MessageQueue .__ callimmediates(blob:http://localhost:8081/55322fd4-9cf7-416d-be9f-be9f-ba5e74a70509:2558:16(
Xcode log:
任务。 LocalDataTask。 " localdatatask。&lt; 1>" (,nslocalizedDescription =不支持的URL} [-1002]
您是否尝试打开NSExceptionAllowsInsecureHTTPLoads
?
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>