Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Why my Imgur API in Javascript doesn't work?

I need to upload my image in imgur with imgur's API, and i do that in Javascript but i have all time a response like "429 - Too many request" or "403 - Imgur is temporarily over capacity. Please try again later". And I also do a API test in PHP but with this i have no problem

I need help to understand why my call API in JS doesn't work

(the file in my function JS come to HTML tag input file multiple)

My JS code

function FolderAddPictureUploadImgur(file) {
    var imgur_client_id = "xxxx";
    
    const formData = new FormData();
    formData.append('image', file);
    
    fetch('https://api.imgur.com/3/image', {
        method: 'POST',
        headers: {
        Authorization: 'Client-ID '+ imgur_client_id,
        },
        body: formData
    }).then(response => {
        console.log(response);
        if (response.ok) {
        alert('Image uploaded to album');       
        }
    }).catch(error => {
        console.error(error);
        //alert('Upload failed: ' + error);
    });
}

My code PHP

<?php
$imgur_client_id = 'xxx';

$file = file_get_contents("test_image.png");

$url = 'https://api.imgur.com/3/image.json';
$headers = array("Authorization: Client-ID $imgur_client_id");
$pvars  = array('image' => base64_encode($file));

$curl = curl_init();
curl_setopt_array($curl, array(
   CURLOPT_URL=> $url,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_POST => 1,
   CURLOPT_RETURNTRANSFER => 1,
   CURLOPT_HTTPHEADER => $headers,
   CURLOPT_POSTFIELDS => $pvars
));

$json_returned = curl_exec($curl); // blank response
echo($json_returned);

$json_returned = json_decode($json_returned, true);

curl_close ($curl); 

?>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!