-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-upload.js
More file actions
38 lines (31 loc) · 915 Bytes
/
test-upload.js
File metadata and controls
38 lines (31 loc) · 915 Bytes
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
const fetch = require('node-fetch');
const walletAddress = 'na';
const privateKey = {
key1: "use your key here",
key2: "wdwd"
};
var data = 'Sample dataset to upload to Arweave';
const backendUrl = 'http://localhost:3000/auth/upload';
async function testUpload() {
try {
const response = await fetch(backendUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ walletAddress, privateKey, data }),
});
const textResponse = await response.text();
console.log("Raw response:", textResponse);
const result = JSON.parse(textResponse);
if (response.ok) {
console.log('Success:', result.message);
console.log('Transaction ID:', result.transactionId);
} else {
console.log('Error:', result.message);
}
} catch (error) {
console.error('Request failed', error);
}
}
testUpload();