Base solution for your next web application
Open Closed

AjaxResponse parsing in generated nswag code problem #5078


User avatar
0
jollyticket created

Hi,

I use Asp.Net Zero project with Asp.Net Core and Angular applications.

I create MyAppService and one method that returns an AjaxResponse<MyDto> object to set result, success and error properties of AjaxResponse. Then through NSwag tool I generate the proxy for Angular but when I call my method on client side, the response doesn't parse correctly because I read only the dto in result property and not the full AjaxResponse. On browser network the response with AjaxResponse seems correctly.

How can I parse correctly the AjaxResponse? I try with WrapResult and DontWrapResult attribute on method but seems don't work.

Thanks


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    You can try something like this;

    import { IAjaxResponse } from '@abp/abpHttpInterceptor';
    ...
    ...
    const ajaxResponse = <IAjaxResponse>JSON.parse(response);