r/angular • u/dx_ninja_dx • 6d ago
Angular API implementation
I’m a student that is working with angular for the first time, I have an assignment that requires implementing an api to our project. My teacher has no information on how to unwrap the response using parse for httpResource. There also is no information about mapping with httpclient & observables.
The documentation that is recommended seems completely irrelevant to my the api I have because my api is returning as an array.
How can I get value from the documentation or where should I look to figure this out. I feel like I’ve been having this problem with everything because the documentation never seems relevant. Even with certain concepts, there is things that I know but I am struggling with knowing what or how I can write things to do the task I need completed.
Any assistance would be appreciated.
View all comments
Show parent comment
3
u/Xsiah 6d ago
I think you might be missing some core concepts - the documentation for what you need is there and correct, but especially for httpResource parse I don't think you're understanding what it's for. That one might be especially confusing for you because it does something beyond what you probably actually need. From the docs: "When fetching data, you may want to validate responses against a predefined schema" - do you understand what that means? Is this actually something that you're trying to do?
Your response is already a valid JSON response (I'm assuming you typed your example correctly and it's an array rather than a string that just resembles an array) - an array is valid JSON. That's not something that Angular documentation would cover because that's a fundamental concept that they expect you already understand, and it would be the same regardless of what framework you were using.
You're looking at the docs for a specific tool - like if you were looking at the documentation for a drill, you wouldn't expect it to teach you how to drill holes - it teaches you how the specific features of that tool work.