!!Help!! What to use to pull data from the API

37 views
Skip to first unread message

IV

unread,
Nov 21, 2019, 11:28:18 AM11/21/19
to Songkick API
Hi,Im trying to pull data from the API, but I cant. This is my code,if you can tell me what Im doing wrong
It says that it cant find property displayName



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
    <title>MusicApp</title>

    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>

</head>

<body>
<form>
<input type="text" id="inputText">
<button type="button" id="submitBtn" class="btn btn-primary"><span
                                class="glyphicon glyphicon-globe"></span> Search </button>
</form>

<div id="text"></div>
<div class="col-sm-8">

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Твоите отбелязвания</h3>
                    </div>

                    <ul class="list-group" style="min-height:241px;" id="contentList">

                        <li class="list-group-item" style="display:none" id="cloneMe">
                            <div class="row">
                                <div class="col-sm-2 col-xs-3">
                                   <!-- <img src="assets/img/icons/clear_sky.png" class="thumbnail img-responsive"> -->
                                </div>
                                <div class="col-sm-7 col-xs-6">
                                    <span class="label label-success"><span class="current-event"> </span> </span>
                                    <h4>Пловдив</h4>
                                    
                                </div>
<div class="col-sm-3 col-xs-3">
                                    <button type="button" class="btn btn-danger pull-right remove-post"><span
                                            class="glyphicon glyphicon-remove"></span><span
                                            class="hidden-xs"> Изтрий</span></button>
                                </div>
                            </div>
                        </li>

                    </ul>
                </div>

            </div>
</body>

<script>
$(document).ready(function(){
    var api="";

    $('#submitBtn').click(function(){
       
artistName=$('#inputText').val();

        $.ajax({
            method:"GET",
url:"https://api.songkick.com/api/3.0/events.json?apikey=" + api + "&artist_name=" + artistName + "&min_date=2009-10-01&max_date=2009-10-30" , 
<!--url:"https://api.songkick.com/api/3.0/search/artists.json?apikey=" + api + "&query=" + artistName, -->
            success:function(resp){
                var miniMe = $('#cloneMe').clone();

                    miniMe.attr('id', '');
                    miniMe.find('h4').text(artistName);
miniMe.find('.current-event').html(resp.displayName);
                    miniMe.find('button').click(function () {
                        miniMe.remove();

                    });

                    miniMe.show();

                    $('#contentList').append(miniMe);

                   
            },
            error:function(){
                alert("Something went wrong!");
            }
        });
        return false;
    });
});


</script>
</html>

Giulio Rondon

unread,
Dec 4, 2019, 6:10:46 AM12/4/19
to Songkick API
It is probably because the key 'displayName' is nested in other properties.


Op donderdag 21 november 2019 17:28:18 UTC+1 schreef IV:
Reply all
Reply to author
Forward
0 new messages