adobe / aem-sample-we-retail-journal

We.Retail Journal is a sample showcasing SPA Editing capabilities in AEM using React and Angular
Apache License 2.0
70 stars 69 forks source link

Development mode React - Code fails in ModelClient while navigating to http://localhost:9000/content/we-retail-journal/react/home.html #13

Closed chaurasiagovind closed 5 years ago

chaurasiagovind commented 5 years ago

Code fails in ModelClient while navigating to http://localhost:9000/content/we-retail-journal/react/home.html

`fetch(modelPath) {

    if (!modelPath) {
        let err = 'Fetching model rejected for path: ' + modelPath;
        return Promise.reject(new Error(err));
    }

    // Either the API host has been provided or we make an absolute request relative to the current host
    let url = `${this._apiHost}${modelPath}`;

    return fetch(url, FETCH_CONFIG).then(function(response) {
        if (response.status >= 200 && response.status < 300) {
            **return response.json();**
        } else {
            let error = new Error('while fetching the model for url: ' + url, response.statusText || response.status);
            error.response = response;

            return Promise.reject(error);
        }
    });
}`

we get an object instead of model.json and model.json request gets delayed then page dosn't load.

Any Ideas.

chaurasiagovind commented 5 years ago

Additional log image

Response ___ body: (...) bodyUsed: false headers: Headers {} ok: true redirected: false status: 200 statusText: "OK" type: "basic" url: "http://localhost:9000/content/we-retail-journal/react.model.json" proto: Response

pfauchere commented 5 years ago

It is a known issue. We are planning to update the documentation to better describe that scenario. To enable the local server to serve the content, please proceed as follow:

[0] https://github.com/adobe/aem-sample-we-retail-journal/blob/master/react-app/src/server/CustomModelClient.js [1] https://github.com/adobe/aem-sample-we-retail-journal/blob/master/react-app/src/index.js#L42

chaurasiagovind commented 5 years ago

Thanks, this seems to be working for me.

norbiorb commented 5 years ago

Reopen issue for bringing the provided information to DEVELOPMENT.md

norbiorb commented 5 years ago

Closing this one as PR #17 is merged