我在响应本机中进行反向地理编码(从lat和lon获取地址)时遇到此错误。
请让我知道是否有任何建议
发生实际错误
SyntaxError:在MessageQueue处navigator.geolocation.getCurrentPosition.enableHighAccuracy(blob:http://localhost:8081/23c307eb-648d-4fee-b83d-d0a4187bcffe:314435:22)处的输入意外结束。在MessageQueue .__ blob:http://localhost:8081/23c307eb-648d-4fee-b83d-d0a4187bcffe:2635:18处的__invokeCallback(blob:http://localhost:8081/23c307eb-648d-4fee-b83d-d0a4187bcffe:2366:18)。__guard(blob:http://localhost:8081/23c307eb-648d-4fee-b83d-d0a4187bcffe:2539:13 ),位于http://localhost:8081/23c307eb-648d-4fee-b83d-d0a4187bcffe:2365:14]的MessageQueue.invokeCallbackAndReturnFlushedQueue(blob:http://localhost:8081/debugger-ui/debuggerWorker.js:80:58)
并且我的代码在下面
fetch( `${ MY URL }?key=${googleLocationAPIKey}&latlng=${lat + "," + long}` ) .then(resp => resp.json()) .then(data => { console.warn("data", data); if (data && data.results && data.results.length) { const result = data.results[0]; var region = { latitude: result.geometry.location.lat, longitude: result.geometry.location.lng, formatted_address: result.formatted_address, latitudeDelta: LATITUDE_DELTA, longitudeDelta: LONGITUDE_DELTA } that.setState({ region }); } }) .catch(err => { //this.getCurrentLocation() console.log(err.message); });
调试时显示错误然后(resp => resp.json())
来自resp
从早上尝试过,但是没有运气,请让我知道任何建议
我在响应本机中得到反向地理编码(从lat和lon获取地址)的错误。请让我知道是否有任何建议实际错误在SyntaxError之后:...的意外结尾...]]
that.setState({region});