scullyio / scully

The Static Site Generator for Angular apps

Home Page:https://scully.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scully useScullyTransferState no provide data on PROD

AlonsoK28 opened this issue Β· comments

🐞 Bug report

Description

I had implemented useScullyTransferState on my app but data.json is not provided on request

πŸ”¬ Minimal Reproduction

  • my-service.ts
/**
   * Get offers by department Computers and Accessories
   */
  getByDepartmentComputersAndAccessories(): Observable<OfferAPIResponse> {
    const url = 'getOffersByDepartmentComputersAndAccessories';
    return this.transferState
      .useScullyTransferState(
        'computersAndAccessories', 
        this.http.get<OfferAPIResponse>(`${this.apiURL}/api/${url}`)
      );
  }

  /**
   * Get offers by department Electronic accessories
   */
  getByDepartmentGamesAndToys(): Observable<OfferAPIResponse> {
    const url = 'getOffersByDepartmentGamesAndToys';
    return this.transferState
      .useScullyTransferState(
        'gamesAndToys',
        this.http.get<OfferAPIResponse>(`${this.apiURL}/api/${url}`)
        )
  }
  • my-component.ts
getCurrentDepartmentData() {
    const routeUrl = this.router.url;

    return of(routeUrl)
      .pipe(
        switchMap(val => this.getCurrentDepartmentObservable(val))
      ).subscribe({
        next: data => {
          if (data[0].offersList.length) {
            this.currentMasonryItems = this.applyOrderBy(data[0].offersList);
            this.showTopContent = true;
            this.showBodyContent = true;
          } else {
            this.noResults = true;
          }
        },
        error: () => {}
      })
  }

also data.json is generated correctly with my API information togheter index.html

Captura de pantalla 2023-05-12 a la(s) 20 54 36

when I visit my app hosted into netlify (https://main--amzmation-ssr-1.netlify.app/) to the route "/" is working well and the response of data.json is well done
Captura de pantalla 2023-05-12 a la(s) 20 56 42

But if try to access using a department URL https://main--amzmation-ssr-1.netlify.app/pcs-y-accesorios the response is empty and the data.json file never is requested

Captura de pantalla 2023-05-12 a la(s) 20 58 39

πŸ’»Your Environment

Angular Version:




Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.10
@angular-devkit/build-angular   14.2.10
@angular-devkit/core            14.2.10
@angular-devkit/schematics      14.2.10
@angular/cli                    14.2.10
@schematics/angular             14.2.10
rxjs                            7.8.0
typescript                      4.8.4

Scully Version:





    "@scullyio/init": "^2.1.41",
    "@scullyio/ng-lib": "^2.1.0",
    "@scullyio/scully": "^2.1.0",
    "@scullyio/scully-plugin-puppeteer": "^2.1.0",

πŸ”₯ Exception or Error

No exception error specifically from scully, the error is displaying on my app because the data source is empty




any advice about this issue ?

in this case for my department called as "pcs-y-accesorios" the data.json file is available at https://main--amzmation-ssr-1.netlify.app/pcs-y-accesorios/data.json but never is requested

was an error on my code

stateTransfer is working very well