react-native 网络请求

                let url = `https://restapi.amap.com/v3/geocode/regeo?output=xml&location=${this.state.coordinate.longitude},${this.state.coordinate.latitude}&key=a2a0942a9bcb59eb7bd0f0bb81a9817b&radius=1000&extensions=all`
                fetch(url)
                    .then((response) => response.text())
                    .then((responseText) => {
                        let xmlContent = responseText
                        parseString(xmlContent,  (err, result) => {
                            let res = JSON.parse(JSON.stringify(result.response))
                            console.warn('xml解析内容',res.regeocode[0].formatted_address[0]);
                            let str = res.regeocode[0].formatted_address[0]
                            this.setState({
                                localAddress:str,
                                isLoading:false,
                                isSuccess:true
                            })
                        });

                    }).done();

你可能感兴趣的:(react-native 网络请求)