Promise error in ASP.NET Boilerplate (Core 2.0 + A

2019-03-02 15:07发布

问题:

I have been using ASP.NET Boilerplate to do CRUD Operations with the database with a REST API client like Postman using custom APIs and so far , it's working quite well.

But then when I move on to the frontend part, there is an unhandled exception in Users Component after logging in with an Admin account. First of all, I can see the list of users that I added, from which I can say the Create and Get operations are running properly (I also tested editing the users and it worked well). When I get to "Deleting" the users, I can see an exception in the console output as shown in the picture:

I thought I had somehow messed up some of the codes, so I redownloaded the whole template and started freshly to performed the delete operation again. The error still persists.

Moreover, when I add my own service class in the service-proxies.tx and export it in its service-proxy.module.ts, and inject the service into the app.component and console.log the response in the constructor, I still get the same exception.

Please help me dig to the root of the problem. Thank you.

Edit 1:

Here is the code in HTML line: 50:

<li>
    <a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(user)">
       <i class="material-icons">delete_sweep</i>{{l('Delete')}}</a>
</li>

On, the TS side, it is calling the delete function with User DTO. On the TS side, the delete(User) looks like:

protected delete(user: UserDto): void {
    abp.message.confirm(
        "Delete user '" + user.fullName + "'?",
        (result: boolean) => {
            if (result) {
                this._userService.delete(user.id)
                    .subscribe(() => {
                        abp.notify.info("Deleted User: " + user.fullName);
                        this.refresh();
                    });
            }
        }
    );
}

Edit 2:

I upgraded the SweetAlert version from 1.1.3 to 2.0.8 and the application fails to even compile. According to some GitHub threads, I'm supposed to override some functions related to the SweetAlert module. But then the error messages say the application cannot even locate .....node_modules\sweetalert\dist\sweetalert.css.js

回答1:

ABP v3.2.0 had a few Breaking Changes:

#2145 Upgrade to sweetalert v2.x. Existing applications should upgrade sweetalert packages to v2.x.

The free template may not have upgraded that yet.

You can upgrade to SweetAlert v2.0.8. Remove the node_modules folder before using yarn.

Update

You can now download v3.4.1 of the template with the SweetAlert upgrade.