PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, July 14, 2022

[FIXED] How can i use/ call maps api in my search box using javascript code to show list of cities

 July 14, 2022     api, frontend, javascript, rest, web-deployment     No comments   

Issue

enter image description here

i m trying to use Rapiapi in my webapplication and trying to use the javascript code to get the name of cities and country by autocomplete but im getting error when i try to search. will anyone be able to help me please.

please find the detail code below

var settings = {
"async": true,
"crossDomain": true,
"url": "https://countries-cities.p.rapidapi.com/location/country/GB/geojson?format=json",
"method": "GET",
"headers": {
    "x-rapidapi-host": "countries-cities.p.rapidapi.com",
    "x-rapidapi-key": "65a1b9fb01mshdd797ad52c65502p1489acjsna4edfe314956"
}

}

$.ajax(settings).done(function(response) {
    console.log(response);
});

function search() {
    var input = document.getElementById('search-bar');
    var allcities = new cities(input);
}

im trying to get the details of cities and country name as the user type in. T

Please help Thanks


Solution

I would suggest using their SDKs.

They provide the following snippet:


var request = require('request');

var options = {
  method: '{{HTTP_METHOD}}',
  url: '{{API_URL}}',
  headers: {
    'x-rapidapi-key': '{{API_KEY}}'
  }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});


Answered By - Createdd
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing