I am trying to use Imgur API to upload image from my react project.
I first made the authorization step which returns a token, my id...But when I try to use the API request after receiving the authorization, I've got an error 400.
createError.js:16 Uncaught (in promise) Error: Request failed with status code 400
{"data":{"error":"Authentication required","request":"\/3\/image","method":"GET"},"success":false,"status":401}
Here is my request
const handleSubmit = (e) => {
e.preventDefault()
var encoded = base64.encode(file[0].path)
console.log("value encoded", encoded)
axios('https://api.imgur.com/3/image', {
method: 'POST',
headers: {
'Authorization': "Client-ID MY_PERSONAL_ID"
},
data: {
'image': encoded
}
})
}
In this link you can find the request for the image upload from imgur. Imgur Request
Moreover, on the Imgur documentation, it says:
Status Code: 400 This error indicates that a required parameter is missing or a parameter has a value that is out of bounds or otherwise incorrect. This status code is also returned when image uploads fail due to images that are corrupt or do not meet the format requirements.
But I don't know what I'm missing.