Skip to main content

Error 400 react native using axios

Comments

2 comments

  • Aleksandar Kostadinov

    Hi,

    Looking at the code you shared I can see a few reasons why you would be getting this error. Firstly, you're defining the 'data' variable and then enclosing it again in an object that results in data = { data: { params... } } which is not correct.

    In addition, you need to double-check the input (Base64 string) to make sure it is in the right format, i.e. it contains the MIME type and encoding e.g data:image/png;base64, followed by the actual Base64 string. More information on that can be found in this support article

    https://support.cloudinary.com/hc/en-us/articles/203125741-Can-I-upload-using-DATA-URI-BASE64-

    I have gone ahead and created a JSFiddle (https://jsfiddle.net/y53qnwzu/) that uses a 1x1 pixel image in Base64 string and uploads it using Axios. You can just set the upload_preset and cloud name and test it out. Then please check the input of your actual code to ensure it follows the same format.

    Please let me know how it goes.

    Best regards,

    Aleksandar

    0
  • darkziosj

    Thanks, data was indeed the problem along with the wrong format thank you for your time.

    0

Post is closed for comments.