You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe what you were looking for in the documentation
No response
Describe the actions that led you to experience the problem
Just following along with the tutorial.
Describe what you want to experience that would fix the problem
I'd like a change to the code which resolves the issue or an explanation about how I can resolve it myself.
Add a screenshot if that helps illustrate the problem
If this problem caused an exception or error, please paste it here
Type 'void' is not assignable to type 'Observable<{ type: string; price: number; }[]>'.(2322)
(property) ShippingComponent.shippingCosts: Observable<{
type: string;
price: number;
}[]>
### If the problem is browser-specific, please specify the device, OS, browser, and version
_No response_
### Provide any additional information here in as much as detail as you can
_No response_
The text was updated successfully, but these errors were encountered:
goodwinchris
changed the title
ngOnInit: void breaks shipping.component.ts
ngOnInit(): void breaks shipping.component.ts
Mar 27, 2024
The code in the tutorial is correct. TypeScript is correctly telling you that in your code, this.cartService.getShippingPrices() is returning void which is not assignable to the Observable. It has nothing to do with ngOnInit or its return type - you likely did not return anything from getShippingPrices().
Describe the problem that you experienced
When following along with the getting started tutorial, I'm prevented from moving forward with the following error:
Enter the URL of the topic with the problem
https://angular.io/start/start-data#configuring-the-shippingcomponent-to-use-cartservice
Describe what you were looking for in the documentation
No response
Describe the actions that led you to experience the problem
Just following along with the tutorial.
Describe what you want to experience that would fix the problem
I'd like a change to the code which resolves the issue or an explanation about how I can resolve it myself.
Add a screenshot if that helps illustrate the problem
If this problem caused an exception or error, please paste it here
The text was updated successfully, but these errors were encountered: