Skip to content

HTTP Exercises#43

Open
NicoAntonelli wants to merge 3 commits intoutnfrrottads:httpfrom
NicoAntonelli:http
Open

HTTP Exercises#43
NicoAntonelli wants to merge 3 commits intoutnfrrottads:httpfrom
NicoAntonelli:http

Conversation

@NicoAntonelli
Copy link
Copy Markdown

No description provided.

const userUrl = this.baseUrl + 'users/login';
this.http.post(userUrl, { user: this.hardcodedUser })
.subscribe((response) => {
const token = response["user"]["token"];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en este caso no deberias usar ["sring"] si te fallaba el tipo podes especifcar en l linea anterior el repsponse como any

haciando
.subscribe((response: any) => {

o bien creano el tipo correspondiente para la respuesta de ese post y haciendo
.subscribe((response: LoginResponse) => {

}
)
.subscribe((res) => { alert("Comment uploaded successfully") }),
(err: any) => { console.log(err); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esta bien esto en un ejercicio como esto pero sino no es conveniente manejar los errores sino los vamos a manear erealmente este comportamiento ya lo hace angular de que si falla te lo muestra por consola, el tema con esto es que al no saltar la excepcion es mas dificil de detectar.

.subscribe((res) => { alert("Comment uploaded successfully") }),
(err: any) => { console.log(err); }
}),
(err: any) => { console.log(err); }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mismo aca

<h1>{{article.title}} </h1>
<div class="tagList">
<div *ngFor="let tag of tags" class="tag">
<span *ngIf="!(tag.indexOf('&zwnj;') > -1)">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

estas comprobaciones mejor hacerlas en un metodo del component no directamente en el template, tratemos de sacar la logica de os templates aunque sea minima

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants