File size: 22,311 Bytes
69996c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
// Shop11 API Functions
// ページビルダーで作成したページで使用するAPI呼び出し関数

document.addEventListener('DOMContentLoaded', function() {
    console.log('✅ Shop11 API Functions loaded');
    
    // すべてのAPIボタンにイベントリスナーを追加
    document.addEventListener('click', function(e) {
        const action = e.target.getAttribute('data-action');
        if (!action) return;
        
        switch(action) {
            case 'goldCheckDelete':
                goldCheckDelete(e.target);
                break;
            case 'createSateiTitle':
                createSateiTitle(e.target);
                break;
            case 'sendNotification':
                sendNotification(e.target);
                break;
            case 'searchProduct':
                searchProduct(e.target);
                break;
            case 'loadProductTable':
                loadProductTable(e.target);
                break;
            case 'clearProductTable':
                clearProductTable(e.target);
                break;
            case 'loadCustomerTable':
                loadCustomerTable(e.target);
                break;
            case 'clearCustomerTable':
                clearCustomerTable(e.target);
                break;
            case 'loadSateiTable':
                loadSateiTable(e.target);
                break;
            case 'clearSateiTable':
                clearSateiTable(e.target);
                break;
            case 'registerProduct':
                registerProduct(e.target);
                break;
        }
    });
});

// 地金チェック削除
function goldCheckDelete(button) {
    const block = button.closest('.shop11-api-block');
    const productId = block.querySelector('.gold-product-id').value;
    const resultDiv = block.querySelector('.gold-check-result');
    
    if (!productId) {
        alert('商品IDを入力してください');
        return;
    }
    
    resultDiv.style.display = 'block';
    resultDiv.innerHTML = '処理中...';
    
    const requestData = { product_id: productId };
    
    fetch('/api/shouhin/gold_check_id_delete', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || ''
        },
        body: JSON.stringify(requestData)
    })
    .then(res => res.json())
    .then(data => {
        resultDiv.innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
        
        // Supabaseにログ保存
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase(
                '地金チェック削除',
                '/api/shouhin/gold_check_id_delete',
                requestData,
                data,
                'success'
            );
        }
    })
    .catch(err => {
        resultDiv.innerHTML = '<span style="color:red;">エラー: ' + err.message + '</span>';
        
        // Supabaseにエラーログ保存
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase(
                '地金チェック削除',
                '/api/shouhin/gold_check_id_delete',
                requestData,
                { error: err.message },
                'error'
            );
        }
    });
}

// 査定タイトル生成
function createSateiTitle(button) {
    const block = button.closest('.shop11-api-block');
    const productId = block.querySelector('.satei-product-id').value;
    const resultDiv = block.querySelector('.satei-title-result');
    
    if (!productId) {
        alert('商品IDを入力してください');
        return;
    }
    
    resultDiv.style.display = 'block';
    resultDiv.innerHTML = '生成中...';
    
    const endpoint = '/api/satei_func/create_title/' + productId;
    const requestData = { product_id: productId };
    
    fetch(endpoint, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        }
    })
    .then(res => res.json())
    .then(data => {
        resultDiv.innerHTML = '<strong>タイトル:</strong><br>' + (data.title || JSON.stringify(data, null, 2));
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('査定タイトル生成', endpoint, requestData, data, 'success');
        }
    })
    .catch(err => {
        resultDiv.innerHTML = '<span style="color:red;">エラー: ' + err.message + '</span>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('査定タイトル生成', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// メール送信
function sendNotification(button) {
    const block = button.closest('.shop11-api-block');
    const to = block.querySelector('.mail-to').value;
    const subject = block.querySelector('.mail-subject').value;
    const body = block.querySelector('.mail-body').value;
    const resultDiv = block.querySelector('.mail-result');
    
    if (!to || !subject || !body) {
        alert('すべての項目を入力してください');
        return;
    }
    
    resultDiv.style.display = 'block';
    resultDiv.innerHTML = '送信中...';
    
    const endpoint = '/api/notification/mail';
    const requestData = { to, subject, body };
    
    fetch(endpoint, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || ''
        },
        body: JSON.stringify(requestData)
    })
    .then(res => res.json())
    .then(data => {
        resultDiv.innerHTML = '<span style="color:green;">✅ 送信完了</span><br><pre>' + JSON.stringify(data, null, 2) + '</pre>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('メール送信', endpoint, requestData, data, 'success');
        }
    })
    .catch(err => {
        resultDiv.innerHTML = '<span style="color:red;">❌ エラー: ' + err.message + '</span>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('メール送信', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// 商品検索
function searchProduct(button) {
    const block = button.closest('.shop11-api-block');
    const keyword = block.querySelector('.search-keyword').value;
    const resultDiv = block.querySelector('.search-result');
    
    if (!keyword) {
        alert('検索キーワードを入力してください');
        return;
    }
    
    resultDiv.style.display = 'block';
    resultDiv.innerHTML = '検索中...';
    
    const endpoint = '/api/auto_complete_refasta/ResultSearch?q=' + encodeURIComponent(keyword);
    const requestData = { keyword };
    
    fetch(endpoint, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        }
    })
    .then(res => res.json())
    .then(data => {
        if (Array.isArray(data) && data.length > 0) {
            let html = '<ul style="list-style:none; padding:0;">';
            data.forEach(item => {
                html += '<li style="padding:10px; border-bottom:1px solid #eee;">' + 
                       (item.label || item.name || JSON.stringify(item)) + '</li>';
            });
            html += '</ul>';
            resultDiv.innerHTML = html;
        } else {
            resultDiv.innerHTML = '検索結果なし';
        }
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('商品検索', endpoint, requestData, data, 'success');
        }
    })
    .catch(err => {
        resultDiv.innerHTML = '<span style="color:red;">エラー: ' + err.message + '</span>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('商品検索', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// 商品データテーブル読込
function loadProductTable(button) {
    const block = button.closest('.shop11-api-block');
    const keyword = block.querySelector('.product-search-keyword').value;
    const tableBody = block.querySelector('.product-table-body');
    const infoDiv = block.querySelector('.product-table-info');
    
    if (!keyword) {
        alert('検索キーワードを入力してください');
        return;
    }
    
    tableBody.innerHTML = '<tr><td colspan="7" class="text-center">🔍 検索中...</td></tr>';
    
    const endpoint = '/api/auto_complete_refasta/ResultSearch?q=' + encodeURIComponent(keyword);
    const requestData = { keyword };
    
    fetch(endpoint, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        }
    })
    .then(res => res.json())
    .then(data => {
        if (Array.isArray(data) && data.length > 0) {
            let html = '';
            data.forEach((item, index) => {
                html += '<tr>';
                html += '<td>' + (item.product_id || item.id || index + 1) + '</td>';
                html += '<td>' + (item.label || item.name || item.title || '-') + '</td>';
                html += '<td>' + (item.brand || item.maker || '-') + '</td>';
                html += '<td>' + (item.category || item.category_name || '-') + '</td>';
                html += '<td class="text-right">' + (item.price ? '¥' + parseInt(item.price).toLocaleString() : '-') + '</td>';
                html += '<td>' + getStatusBadge(item.status) + '</td>';
                html += '<td>' +
                       '<button class="btn btn-sm btn-info mr-1" onclick="alert(\'商品ID: ' + (item.product_id || item.id) + '\')">📝 詳細</button>' +
                       '<button class="btn btn-sm btn-warning" onclick="alert(\'編集機能は準備中です\')">✏️ 編集</button>' +
                       '</td>';
                html += '</tr>';
            });
            tableBody.innerHTML = html;
            infoDiv.innerHTML = '<small>✅ ' + data.length + '件の商品が見つかりました</small>';
            
            if (window.saveApiLogToSupabase) {
                saveApiLogToSupabase('商品データテーブル読込', endpoint, requestData, { count: data.length }, 'success');
            }
        } else {
            tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-muted">📭 検索結果なし</td></tr>';
            infoDiv.innerHTML = '<small>検索結果: 0件</small>';
            
            if (window.saveApiLogToSupabase) {
                saveApiLogToSupabase('商品データテーブル読込', endpoint, requestData, { count: 0 }, 'success');
            }
        }
    })
    .catch(err => {
        tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-danger">❌ エラー: ' + err.message + '</td></tr>';
        infoDiv.innerHTML = '<small class="text-danger">データ読込エラー</small>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('商品データテーブル読込', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// 商品テーブルクリア
function clearProductTable(button) {
    const block = button.closest('.shop11-api-block');
    const keyword = block.querySelector('.product-search-keyword');
    const tableBody = block.querySelector('.product-table-body');
    const infoDiv = block.querySelector('.product-table-info');
    
    keyword.value = '';
    tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-muted">検索キーワードを入力して検索してください</td></tr>';
    infoDiv.innerHTML = '';
}

// ステータスバッジ生成
function getStatusBadge(status) {
    if (!status) return '<span class="badge badge-secondary">-</span>';
    
    const statusMap = {
        '1': { label: '在庫あり', color: 'success' },
        '2': { label: '予約中', color: 'warning' },
        '3': { label: '売約済', color: 'danger' },
        '4': { label: '出品中', color: 'info' },
        '5': { label: '取り下げ', color: 'secondary' }
    };
    
    const statusInfo = statusMap[status] || { label: status, color: 'secondary' };
    return '<span class="badge badge-' + statusInfo.color + '">' + statusInfo.label + '</span>';
}

// 顧客データテーブル読込
function loadCustomerTable(button) {
    const block = button.closest('.shop11-api-block');
    const keyword = block.querySelector('.customer-search-keyword').value;
    const tableBody = block.querySelector('.customer-table-body');
    const infoDiv = block.querySelector('.customer-table-info');
    
    if (!keyword) {
        alert('検索キーワードを入力してください');
        return;
    }
    
    tableBody.innerHTML = '<tr><td colspan="7" class="text-center">🔍 検索中...</td></tr>';
    
    const endpoint = '/api/Eoc/search?keyword=' + encodeURIComponent(keyword);
    const requestData = { keyword };
    
    fetch(endpoint, {
        method: 'GET',
        headers: { 'Content-Type': 'application/json' }
    })
    .then(res => res.json())
    .then(data => {
        const customers = Array.isArray(data) ? data : (data.data || []);
        
        if (customers.length > 0) {
            let html = '';
            customers.forEach(customer => {
                html += '<tr>';
                html += '<td>' + (customer.ecc_id || customer.id || '-') + '</td>';
                html += '<td>' + (customer.name1 || customer.name || '-') + '</td>';
                html += '<td>' + (customer.tel || customer.phone || '-') + '</td>';
                html += '<td>' + (customer.mail1 || customer.email || '-') + '</td>';
                html += '<td>' + (customer.zip1 || customer.zip || '-') + '</td>';
                html += '<td>' + (customer.address1 || customer.address || '-') + '</td>';
                html += '<td>' +
                       '<button class="btn btn-sm btn-info mr-1" onclick="alert(\'顧客ID: ' + (customer.ecc_id || customer.id) + '\')">📋 詳細</button>' +
                       '<button class="btn btn-sm btn-primary" onclick="alert(\'編集機能は準備中です\')">✏️ 編集</button>' +
                       '</td>';
                html += '</tr>';
            });
            tableBody.innerHTML = html;
            infoDiv.innerHTML = '<small>✅ ' + customers.length + '件の顧客が見つかりました</small>';
            
            if (window.saveApiLogToSupabase) {
                saveApiLogToSupabase('顧客検索テーブル', endpoint, requestData, { count: customers.length }, 'success');
            }
        } else {
            tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-muted">📭 検索結果なし</td></tr>';
            infoDiv.innerHTML = '<small>検索結果: 0件</small>';
        }
    })
    .catch(err => {
        tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-danger">❌ エラー: ' + err.message + '</td></tr>';
        infoDiv.innerHTML = '<small class="text-danger">データ読込エラー</small>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('顧客検索テーブル', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// 顧客テーブルクリア
function clearCustomerTable(button) {
    const block = button.closest('.shop11-api-block');
    block.querySelector('.customer-search-keyword').value = '';
    block.querySelector('.customer-table-body').innerHTML = '<tr><td colspan="7" class="text-center text-muted">検索キーワードを入力して検索してください</td></tr>';
    block.querySelector('.customer-table-info').innerHTML = '';
}

// 査定データテーブル読込
function loadSateiTable(button) {
    const block = button.closest('.shop11-api-block');
    const keyword = block.querySelector('.satei-search-keyword').value;
    const tableBody = block.querySelector('.satei-table-body');
    const infoDiv = block.querySelector('.satei-table-info');
    
    if (!keyword) {
        alert('検索キーワードを入力してください');
        return;
    }
    
    tableBody.innerHTML = '<tr><td colspan="7" class="text-center">🔍 検索中...</td></tr>';
    
    const endpoint = '/api/satei/search?keyword=' + encodeURIComponent(keyword);
    const requestData = { keyword };
    
    fetch(endpoint, {
        method: 'GET',
        headers: { 'Content-Type': 'application/json' }
    })
    .then(res => res.json())
    .then(data => {
        const sateiList = Array.isArray(data) ? data : (data.data || []);
        
        if (sateiList.length > 0) {
            let html = '';
            sateiList.forEach(satei => {
                html += '<tr>';
                html += '<td>' + (satei.id || '-') + '</td>';
                html += '<td>' + (satei.product_name || satei.title || '-') + '</td>';
                html += '<td>' + (satei.customer_name || satei.ecc_name || '-') + '</td>';
                html += '<td class="text-right">' + (satei.price ? '¥' + parseInt(satei.price).toLocaleString() : '-') + '</td>';
                html += '<td>' + (satei.satei_date || satei.created_at || '-') + '</td>';
                html += '<td>' + getSateiStatusBadge(satei.status) + '</td>';
                html += '<td>' +
                       '<button class="btn btn-sm btn-info mr-1" onclick="alert(\'査定ID: ' + (satei.id) + '\')">📋 詳細</button>' +
                       '<button class="btn btn-sm btn-warning" onclick="alert(\'編集機能は準備中です\')">✏️ 編集</button>' +
                       '</td>';
                html += '</tr>';
            });
            tableBody.innerHTML = html;
            infoDiv.innerHTML = '<small>✅ ' + sateiList.length + '件の査定が見つかりました</small>';
            
            if (window.saveApiLogToSupabase) {
                saveApiLogToSupabase('査定検索テーブル', endpoint, requestData, { count: sateiList.length }, 'success');
            }
        } else {
            tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-muted">📭 検索結果なし</td></tr>';
            infoDiv.innerHTML = '<small>検索結果: 0件</small>';
        }
    })
    .catch(err => {
        tableBody.innerHTML = '<tr><td colspan="7" class="text-center text-danger">❌ エラー: ' + err.message + '</td></tr>';
        infoDiv.innerHTML = '<small class="text-danger">データ読込エラー</small>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('査定検索テーブル', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}

// 査定テーブルクリア
function clearSateiTable(button) {
    const block = button.closest('.shop11-api-block');
    block.querySelector('.satei-search-keyword').value = '';
    block.querySelector('.satei-table-body').innerHTML = '<tr><td colspan="7" class="text-center text-muted">検索キーワードを入力して検索してください</td></tr>';
    block.querySelector('.satei-table-info').innerHTML = '';
}

// 査定ステータスバッジ
function getSateiStatusBadge(status) {
    const statusMap = {
        '1': { label: '査定中', color: 'info' },
        '2': { label: '査定完了', color: 'success' },
        '3': { label: '買取完了', color: 'primary' },
        '4': { label: 'キャンセル', color: 'danger' }
    };
    const statusInfo = statusMap[status] || { label: status || '-', color: 'secondary' };
    return '<span class="badge badge-' + statusInfo.color + '">' + statusInfo.label + '</span>';
}

// 商品登録
function registerProduct(button) {
    const block = button.closest('.shop11-api-block');
    const form = block.querySelector('.product-register-form');
    const resultDiv = block.querySelector('.register-result');
    
    const name = block.querySelector('.product-name').value;
    const brand = block.querySelector('.product-brand').value;
    const category = block.querySelector('.product-category').value;
    const price = block.querySelector('.product-price').value;
    const description = block.querySelector('.product-description').value;
    const status = block.querySelector('.product-status').value;
    
    if (!name || !price) {
        alert('商品名と価格は必須です');
        return;
    }
    
    resultDiv.style.display = 'block';
    resultDiv.innerHTML = '💾 登録中...';
    
    const endpoint = '/api/shouhin/register';
    const requestData = {
        name: name,
        brand: brand,
        category: category,
        price: price,
        description: description,
        status: status
    };
    
    fetch(endpoint, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || ''
        },
        body: JSON.stringify(requestData)
    })
    .then(res => res.json())
    .then(data => {
        resultDiv.innerHTML = '<div class="alert alert-success">✅ 商品を登録しました!<br>商品ID: ' + (data.product_id || data.id || '不明') + '</div>';
        form.reset();
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('商品登録', endpoint, requestData, data, 'success');
        }
    })
    .catch(err => {
        resultDiv.innerHTML = '<div class="alert alert-danger">❌ エラー: ' + err.message + '</div>';
        
        if (window.saveApiLogToSupabase) {
            saveApiLogToSupabase('商品登録', endpoint, requestData, { error: err.message }, 'error');
        }
    });
}