Closed yozawiratama closed 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,
]
my friends said this is a cors problem
but I think as long as I have signature, there is no cors problem, right?
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.
is this solve getting same error, using the imagekit-javascript
Seems like a network problem. Please share the minimum code to reproduce the problem.