私はジェネレータによって定義されたconfig.jsファイルを持っています。反応アプリケーションのグローバル設定オブジェクトを使用
'use strict';
import baseConfig from './base';
let config = {
appEnv: 'dev', // feel free to remove the appEnv property here,
baseUrl:'https://mod970274.sharepoint.com',//'http://maliye.milliemlak.gov.tr',
listName:''
};
export default Object.freeze(Object.assign({}, baseConfig, config));
ここではそれをどのように呼びますか。
import config from 'config';
class FooterState {
@observable items =[];
constructor(){
config.listName = 'FooterMenu';
this.getItems();
}
getItems() {
fetch(`${config.baseUrl}/_api/web/lists/getbytitle('${config.listName}')/items`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
しかし、例を使用しても、コンストラクタでは未定義の例外がスローされます。これは、それがどのように見えるかです:
は、どのように私はプロジェクト