2
respostas

core.js:1598 ERROR DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

Ao usar o *ngIf="(photo$ | async) as photo" passa a dar o erro abaixo ao acessar qualquer detalhe. Exemplo de link que dá erro:

"http://localhost:4200/#/p/17", "http://localhost:4200/#/p/13"

core.js:1598 ERROR DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
    at http://localhost:4200/polyfills.js:5306:31
    at XMLHttpRequest.proto.<computed> [as open] (http://localhost:4200/polyfills.js:3716:24)
    at Observable._subscribe (http://localhost:4200/vendor.js:7738:17)
    at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (http://localhost:4200/vendor.js:67371:69)
    at http://localhost:4200/vendor.js:83875:31
    at subscribeToResult (http://localhost:4200/vendor.js:84058:84)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._innerSub (http://localhost:4200/vendor.js:76846:99)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (http://localhost:4200/vendor.js:76843:14)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (http://localhost:4200/vendor.js:76826:18)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (http://localhost:4200/vendor.js:68161:18)
2 respostas

Meu Service estava errado:

findById(id: string) {
        return this.http.get<Photo>(API + 'photos' + id);
    }

O correto seria:

findById(id: string) {
        return this.http.get<Photo>(API + '/photos/' + id);
    }

Oi, Ricardo, tudo bem?

Conseguiu resolver o seu problema? Muito obrigada por compartilhar sua solução conosco :}

Bons estudos!