-1

I am using intlTelInput in plain HTML/CSS using below code and it's working fine you can see the demo (intl-tel-input sample).

HTML code

<label for="phone" class="control-label">Mobile Phone Number</label><br/>
<input type="tel" class="form-control" id="phone" placeholder="">

Javascript code

 <script>
 var input = document.querySelector("#phone");
intlTelInput(input, {
initialCountry: "auto",
geoIpLookup: function(success, failure) {
    $.get("https://ipinfo.io", function() {}, "jsonp").always(function(resp) {
        var countryCode = (resp && resp.country) ? resp.country : "";
        success(countryCode);
    });
},
utilsScript: "css/intl-tel-input-master/build/js/utils.js"
});

Now, I am using the same code in laravel and it shows me nothing. Can you please tell me how to solve the issue?

GET https://ipinfo.io/?callback=jQuery11110941559198167627&=1559198167628 net::ERR_ABORTED 429

Asma Ahmad
  • 408
  • 1
  • 3
  • 15

3 Answers3

0

This has nothing to do with Laravel. If you try your javascript code outside of Laravel you should find you get the same error.

429 TOO MANY REQUESTS
The user has sent too many requests in a given amount of time ("rate limiting").

A 429 error suggests you have exceeded the request limit for the ipinfo.io API.

Looking on ipinfo.io it shows that the free tier of only allows a maximum of 1000 requests per day. Could you have exceeded that amount?

Jeemusu
  • 10,415
  • 3
  • 42
  • 64
  • no. I just try to run my code it didn't work and only show me this error – Asma Ahmad May 30 '19 at 07:33
  • @AsmaAhmad how many request had you made this month? maybe your request reach its limit for this API. as your error suggest net::ERR_ABORTED 429. https://httpstatuses.com/429 – Julius Limson May 30 '19 at 07:58
  • i am using from yesterday and send approximately 20,30 requests – Asma Ahmad May 30 '19 at 08:01
  • Move the code outside of Laravel, try it again, do you get the same error? API error codes don't lie, to quote the ipinfo.io website `Free usage of our API is limited to 1,000 API requests per day. If you exceed 1,000 requests in a 24 hour period we'll return a 429 HTTP status code to you.` Are you testing this from a locally hosted website, are you the only one accessing it? Could it be possible that other people have accessed it which has caused you to go over your limit? – Jeemusu May 30 '19 at 08:48
  • @AsmaAhmad Login to your ipinfo.io account, on the [dashboard](https://imgur.com/SxxoNvO) there is an area where it shows you how many requests you have made. How many does it show? – Jeemusu May 30 '19 at 08:54
0

This may be too late to answer but apparently when your try to serve on a defined host like dev.com or the machine IP might resolve the error 429.

Serve your Laravel instance ei:

$ php artisan serve --host=192.168.2.23
Adro
  • 675
  • 13
  • 27
-1

For future reference, here is the answer

Links in head tag

<link rel="stylesheet" href="{{ asset ('css/intl-tel-input/build/css/intlTelInput.css') }}"/>
<script src="{{ asset ('css/intl-tel-input/build/js/intlTelInput.min.js') }}"></script>

Html code

<input type="tel" id="phone" placeholder="">

Script

<script>
var input = document.querySelector("#phone");
window.intlTelInput(input);
</script>
Asma Ahmad
  • 408
  • 1
  • 3
  • 15