Company: Swiggy
Difficulty: medium
REST API: Capital City Given a country name, query the REST API at https://jsonmock.hackerrank.com/api/countries?name=country and return the capital city\'s name. The response is a JSON object with 5 fields. The essential field is data : data : Either an empty array or an array with a single object that contains the country\'s record. In the data array, the country has the following schema: name : The name of the country (String) capital : The name of the capital city (String) A number of fields that are not of interest. Note: page , per_page , total , total_pages etc., are not required for this task. If the country is found, the data array contains exactly 1 element. If not, it is empty, and the function should return \'-1\'. Function Description Complete the getCapitalCity function in the editor. getCapitalCity has the following parameters: string country : the country to query Returns string : the capital city or \'-1\' Constraints The returned JSON object contains either 0 or 1 rec