I'm trying to upload a image using html form with imgur api(react).
I've selected OAuth 2 authorization with a callback URL when registering api.
The problem is that api is wont work with error 429 (sometimes net::ERR_HTTP2_PROTOCOL_ERROR).
This is the code
const imageUpload = (e) => {
console.log("called");
var fileIn = e.target;
var file = fileIn.files[0];
if (file && file.size < 5e6) {
const formData = new FormData();
formData.append("image", file);
fetch("https://api.imgur.com/3/image", {
method: "POST",
headers: {
Authorization: "Client-ID //my client Id",
Accept: "application/json",
},
body: formData,
})
.then((response) => response.json())
.then((response) => {
e.preventDefault();
console.log(response);
console.log(response.data.link);
url_in = response.data.link;
});
} else {
console.error("oversized file");
}
}
This is input tag code
<input type="file" name="image" id="upload" onChange={imageUpload}></input>
I just need the url of the uploaded image