Question: I have Multiple buttons that when clicked add an item to a list. I'm trying to make it so that similar items will be one after the other. I'm trying to accomplish this by using JQuery.

These are my buttons:

```
   @foreach (var Dish in item.Dishes)
   {
     <button onclick="AddItem('@Dish.DishName','@Dish.Price',@Dish.DishId)">@Dish.DishName</button>
     }

```

My JQuery function:

```
function AddItem(Name, Price, ID) {
            ID = "Dish" + ID;
            var arr = document.querySelectorAll("#" + ID);
            if (arr.length = 0)
        {
                $(".order").append(
                    $('<li/>').attr("id", ID).addClass("list-group-item").text(Name).append(
                        $('<span/>').addClass("badge").text(Price)
                    ));

            }
            else {
                arr[0].append(
                    $('<li/>').attr("id", ID).addClass("list-group-item").text(Name).append(
                        $('<span/>').addClass("badge").text(Price)
                    ));
            }
            }

```

I'm getting an error that says:
**Uncaught TypeError: Cannot read property 'append' of undefined
at AddItem
at HTMLButtonElement.onclick**

I'm not understading what's undefined and why.

Any advice would be very helpful and if something isn't clear please ask.

Thanx in advance

Answer: 
It is not said what type of authentication you are using, but I suppose you want to add the claims to the `access_token` from where they can be read by on the API.

`AdditionalClaims` on `IdentityServerUser` are only added to the cookie in your client.

What you have to do is to create a profile service (<https://docs.identityserver.io/en/latest/reference/profileservice.html>).

At the simplest it will be something like this:

```
public class ProfileService : IProfileService
{
    private UserService _userService;

    public ProfileService(UserService userService)
    {
        _userService = userService;
    }

    public Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        var user = await _userService.GetUserByIdAsync(context.Subject.GetSubjectId());
        context.IssuedClaims.AddRange(user.Claims);
        return Task.FromResult(0);
    }

    public Task IsActiveAsync(IsActiveContext context)
    {
        var user = await _userService.GetUserByIdAsync(context.Subject.GetSubjectId());
        context.IsActive = user.IsActive;

        return Task.FromResult(0);
    }
}

```

And register it in the Startup.cs:

```
services.AddIdentityServer()
        .AddProfileService<ProfileService>();

```

These can then be read from the access\_token on the API side (if that's what you wanted as it is not clear from the question):

```
var user = User.Identity as ClaimsIdentity;
var claims = user.Claims;

```
You need to explicitly map those extra claims in your client, using code like:

```
options.ClaimActions.MapUniqueJsonKey("website", "website");
options.ClaimActions.MapUniqueJsonKey("gender", "gender");
options.ClaimActions.MapUniqueJsonKey("birthdate", "birthdate");

```

There is also this option you can set:

```
options.GetClaimsFromUserInfoEndpoint = true;

```