React JS 请求服务端接口

(1) web端 请求接口:


  
    
    
    
  
  
    
  


(2) React Native 请求接口:


var Follow = React.createClass({
	//构造数据源
	getInitialState: function() {
		return {
		};
	},
	componentDidMount:function(){
		this.fetchData();
	},
	fetchData: function() {
		fetch("http://localhost:8080/emalldemo/ProductsServlet?action=productlist")
		.then(response => response.text())
		.then(responseText => {
			alert(responseText);
		})
		.catch((error) => {
			alert("error");
		});
	},
	render: function() {
		var HouseCell = require('./HouseCell');
		var nav = this.props.navigator;
 		return (
 
				
				   
 					 
				

			);
	}
});



你可能感兴趣的:(React)