@@ -219,11 +219,25 @@ The `upload()` method requires at least the `file` and the `fileName` parameter
219219
220220Sample usage
221221```
222+ // Using Callback Function
223+
222224imagekit.upload({
223- file : <url|base_64|binary>, //required
224- fileName : "my_file_name.jpg", //required
225+ file : <url|base_64|binary>, //required
226+ fileName : "my_file_name.jpg", //required
225227}, function(error, result) {
228+ if(error) console.log(error);
229+ else console.log(result);
230+ });
231+
232+ // Using Promises
226233
234+ imagekit.upload({
235+ file : <url|base_64|binary>, //required
236+ fileName : "my_file_name.jpg", //required
237+ }).then(response => {
238+ console.log(response);
239+ }).catch(error => {
240+ console.log(error);
227241});
228242```
229243
@@ -246,7 +260,9 @@ Accepts an object specifying the parameters to be used to list and search files.
246260imagekit.listFiles({
247261 skip : 10,
248262 limit : 10
249- }, function(err, result) {
263+ }, function(error, result) {
264+ if(error) console.log(error);
265+ else console.log(result);
250266});
251267
252268
@@ -256,9 +272,9 @@ imagekit.listFiles({
256272 skip : 10,
257273 limit : 10
258274}).then(response => {
259-
260- }).catch(err => {
261-
275+ console.log(response);
276+ }).catch(error => {
277+ console.log(error);
262278});
263279```
264280
@@ -269,18 +285,19 @@ Accepts the file ID and fetches the details as per the [API documentation here](
269285```
270286// Using Callback Function
271287
272- imagekit.getFileDetails("file_id", function(err, result) {
273-
288+ imagekit.getFileDetails("file_id", function(error, result) {
289+ if(error) console.log(error);
290+ else console.log(result);
274291});
275292
276293
277294// Using Promises
278295
279296imagekit.getFileDetails("file_id")
280- .then(response => {
281-
282- }).catch(err => {
283-
297+ }) .then(response => {
298+ console.log(response);
299+ }).catch(error => {
300+ console.log(error);
284301});
285302```
286303
@@ -291,18 +308,19 @@ Accepts the file ID and fetches the metadata as per the [API documentation here]
291308```
292309// Using Callback Function
293310
294- imagekit.getFileMetadata("file_id", function(err, result) {
295-
311+ imagekit.getFileMetadata("file_id", function(error, result) {
312+ if(error) console.log(error);
313+ else console.log(result);
296314});
297315
298316
299317// Using Promises
300318
301319imagekit.getFileMetadata("file_id")
302- .then(response => {
303-
304- }).catch(err => {
305-
320+ }) .then(response => {
321+ console.log(response);
322+ }).catch(error => {
323+ console.log(error);
306324});
307325```
308326
@@ -316,8 +334,9 @@ Update parameters associated with the file as per the [API documentation here](h
316334imagekit.updateFileDetails("file_id", {
317335 tags : ['image_tag'],
318336 customCoordinates : "10,10,100,100"
319- }, function(err, result) {
320-
337+ }, function(error, result) {
338+ if(error) console.log(error);
339+ else console.log(result);
321340});
322341
323342
@@ -326,11 +345,10 @@ imagekit.updateFileDetails("file_id", {
326345imagekit.updateFileDetails("file_id", {
327346 tags : ['image_tag'],
328347 customCoordinates : "10,10,100,100"
329- })
330- .then(response => {
331-
332- }).catch(err => {
333-
348+ }).then(response => {
349+ console.log(response);
350+ }).catch(error => {
351+ console.log(error);
334352});
335353```
336354
@@ -342,18 +360,19 @@ Delete a file as per the [API documentation here](https://docs.imagekit.io/api-r
342360
343361// Using Callback Function
344362
345- imagekit.deleteFile("file_id", function(err, result) {
346-
363+ imagekit.deleteFile("file_id", function(error, result) {
364+ if(error) console.log(error);
365+ else console.log(result);
347366});
348367
349368
350369// Using Promises
351370
352371imagekit.deleteFile("file_id"})
353- .then(response => {
354-
355- }).catch(err => {
356-
372+ }) .then(response => {
373+ console.log(response);
374+ }).catch(error => {
375+ console.log(error);
357376});
358377```
359378
@@ -365,18 +384,19 @@ Delete multiple file as per the [API documentation here](https://docs.imagekit.i
365384
366385// Using Callback Function
367386
368- imagekit.bulkDeleteFiles(["fileIds"], function(err, result) {
369-
387+ imagekit.bulkDeleteFiles(["fileIds"], function(error, result) {
388+ if(error) console.log(error);
389+ else console.log(result);
370390});
371391
372392
373393// Using Promises
374394
375395imagekit.bulkDeleteFiles(["fileIds"])
376- .then(response => {
377-
378- }).catch(err => {
379-
396+ }) .then(response => {
397+ console.log(response);
398+ }).catch(error => {
399+ console.log(error);
380400});
381401```
382402
@@ -387,18 +407,19 @@ Programmatically issue a cache clear request as per the [API documentation here]
387407```
388408// Using Callback Function
389409
390- imagekit.purgeCache("full_url", function(err, result) {
391-
410+ imagekit.purgeCache("full_url", function(error, result) {
411+ if(error) console.log(error);
412+ else console.log(result);
392413});
393414
394415
395416// Using Promises
396417
397418imagekit.purgeCache("full_url")
398- .then(response => {
399-
400- }).catch(err => {
401-
419+ }) .then(response => {
420+ console.log(response);
421+ }).catch(error => {
422+ console.log(error);
402423});
403424```
404425
@@ -409,18 +430,19 @@ Get the purge cache request status using the request ID returned when a purge ca
409430```
410431// Using Callback Function
411432
412- imagekit.getPurgeCacheStatus("cache_request_id", function(err, result) {
413-
433+ imagekit.getPurgeCacheStatus("cache_request_id", function(error, result) {
434+ if(error) console.log(error);
435+ else console.log(result);
414436});
415437
416438
417439// Using Promises
418440
419441imagekit.getPurgeCacheStatus("cache_request_id")
420- .then(response => {
421-
422- }).catch(err => {
423-
442+ }) .then(response => {
443+ console.log(response);
444+ }).catch(error => {
445+ console.log(error);
424446});
425447```
426448
0 commit comments