Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript fetch API

fetch('https://shazam.p.rapidapi.com/search?term=kiss%20the%20rain&locale=en-US&offset=0&limit=5', {
    // request method
    method: 'GET',

    // headers from the API documentation
    headers: {
        'X-RapidAPI-Key': '8bd90c4cffmsh2788964981ec641p113417jsn3d0aff3880f5',
        'X-RapidAPI-Host': 'shazam.p.rapidapi.com'
    }
})
   .then((result) => result.json())  // result from API endpoint
   .then((data) => console.log(data))  // result in json format
   .catch((error) => console.log(error));  // catching the error should it occur
Source by programwithviggo.42web.io #
 
PREVIOUS NEXT
Tagged: #JavaScript #fetch #API
ADD COMMENT
Topic
Name
4+4 =