imagekit-developer / imagekit-javascript

Javascript SDK for using ImageKit.io
https://imagekit.io
77 stars 26 forks source link

I got network error issues using this in react native #27

Closed yozawiratama closed 3 years ago

imagekitio commented 3 years ago

Seems like a network problem. Please share the minimum code to reproduce the problem.

yozawiratama commented 3 years ago

just like the example

import axios from 'axios';
import ImageKit from 'imagekit-javascript';
import { IMAGE_OPTIMIZER } from '../../../config/configHandler';
import { UTIL_URL } from '../../../config/apiHostHandler';

const ImageService = () => {

    const getSignature = async () => {
        const response = await axios.get(`${UTIL_URL}/image/signature`);
        return response.data;
    }

    const Optimize = async ({ imageUri, blobFile, tags, fileName }) => {
        var imagekit = new ImageKit({
            publicKey: IMAGE_OPTIMIZER.publicKey,
            urlEndpoint: IMAGE_OPTIMIZER.urlEndpoint,
            authenticationEndpoint: `${UTIL_URL}/image/signature`
        });
        imagekit.upload({
            file: blobFile,
            fileName,
            tags
        }, function (err, result) {
            console.log('optimize : ');
            console.log('error: ', err);
            console.log(result);
            console.log(arguments);
        })
    }

    return {
        Optimize,
        getSignature
    }
}

module.exports = ImageService;

before I use imagekit-javascript, I use axios form data but it got same error

optimize : 
error:  Object {
  "help": "",
  "message": "Request to ImageKit upload endpoint failed due to network error",
}
null
Arguments [
  Object {
    "help": "",
    "message": "Request to ImageKit upload endpoint failed due to network error",
  },
  null,
]
yozawiratama commented 3 years ago

my friends said this is a cors problem

but I think as long as I have signature, there is no cors problem, right?

imagekitio commented 3 years ago

If image/signature seems to be the signature API that you have implemented on the backend. If this is failing because of CORS then you have set correct headers on the response in your backend.

shaantanu9 commented 5 months ago

is this solve getting same error, using the imagekit-javascript