# Liked variable showing null

**URL:** <https://meta.discourse.org/t/liked-variable-showing-null/96603>\
**Category:** Development\
**Created:** [September 7, 2018, 8:40am UTC](https://meta.discourse.org/t/liked-variable-showing-null/96603 "2018-09-07T08:40:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edwin\_Mhoy\_Silva](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/edwin_mhoy_silva/32/109980_2.png) [@Edwin\_Mhoy\_Silva](https://meta.discourse.org/u/Edwin_Mhoy_Silva)\
**Post date:** [September 7, 2018, 8:40am UTC](https://meta.discourse.org/t/liked-variable-showing-null/96603/1 "2018-09-07T08:40:47Z")

</div>

I have made a method which changes the color of the like button to red, when it has been liked.  
The method changes the color, based on if the variable “Liked” from topics is TRUE or FALSE.  
My problem is that this variable show false, even when it has been liked

 ![postman](https://global.discourse-cdn.com/meta/original/3X/0/f/0f94514f2939e88df00169a4dfdc9193df8b2ff1.png)

This is my like method

```plaintext

 function likeIdea(likesId, idea_id, like) {
        if (notLogedIn == true) {
            loginRequired();
        } else {
            $.post('/post_actions?id=' + idea_id + '&post_action_type_id=2&flag_topic=false?' + Date.now(), {
                headers: {
                    'X-CSRF-Token': getCsrftoken(),
                    'X-Requested-With': 'XMLHttpRequest'
                }
            }).done(function (data) {
                like += 1;
                $('.like' + idea_id).html(like);
                $("#likes" + likesId).addClass('likesRed');

                //$('button').addClass('likesRed');

            }).fail(function (xhr, status, error) {
                console.dir(xhr.responseText);
                if (xhr.status == 422) {
                    alert("like did not go through");
                }
            });
        }
    }

```

I have tried to like and unlike, but it’s still false.  
Some og the likes go trough.
