我是 React.js 的新手,我已经实现了一个组件,从服务器获取数据并使用它,如下:
CallEnterprise:function(TenantId){
fetchData('http://xxx.xxx.xx.xx:8090/Enterprises?TenantId='+TenantId+' &format=json').then(function(enterprises)
{
EnterprisePerspectiveActions.getEnterprise(enterprises);
}).catch(function()
{
alert("There was some issue in API Call please contact Admin");
//ComponentAppDispatcher.handleViewAction({
// actionType: MetaItemConstants.RECEIVE_ERROR,
// error: 'There was a problem getting the enterprises'
//});
});
},
我想将URL存储在配置文件中,这样当我将其部署到测试服务器或生产服务器时,只需更改配置文件中的URL,而不是js文件中的URL。但我不知道如何在react.js中使用配置文件。
请问有人能指导我如何实现这一点吗?