1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Return object looks a bit weird

Discussão em 'Angular' iniciado por Gee, Novembro 5, 2024 às 15:43.

  1. Gee

    Gee Guest

    Good day, currently working on a side project using .Net and angular my controller for adding reviews looking like the following:

    [HttpPost("add-review")]
    public async Task<ActionResult<Review>> CreateReview(ReviewDto reviewDto)
    {
    var results = await _reviewRepository.CreateReviewAsync(reviewDto);
    return Ok(results);
    }


    and my angular side looks like this first portion is the component.ts and second portion is the service

    //component method
    createReview() {
    const id = parseInt(this.route.snapshot.paramMap.get('id'));

    this.reviewService.createReview({ ...this.review, productId: id }).subscribe(results => {
    console.log(results)
    }, error => {
    console.log(error);
    })
    }
    //service
    createReview(review: Review): Observable<Review> {
    return this.http.post<Review>(`${this.baseUrl}review/add-review`, review);
    }



    I am able to create the review successfully, however the results i get from the request looks something like this:

    {results: null, value: {body: 'test', productId: 1, id; 11, rating: 2}


    any assistance will be much appreciated

    Continue reading...

Compartilhe esta Página