-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean-warnings.js
54 lines (51 loc) · 1.42 KB
/
clean-warnings.js
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
import axios from 'axios'
import {DeviceAuthorization, apiUrl, deviceId, xApiKey} from './credentials.js'
//const getToken = `${apiUrl}/get-token/`
const warnings = `${apiUrl}/project/details`
const deleteWarning = `${apiUrl}/manage/warnings`
const bearerToken = process.env.BEARER_TOKEN
// const token = axios.post(getToken, {
// username,
// password
// })
// .then(response => {
// //console.log(response.data)
// const result = response.data.access
// //console.log(`This is the token: ${result}`)
// return result
// })
// .catch(error => {
// console.log(`Token error: ${error}`);
// });
await axios
.get(warnings, {
params: {
id: 47,
},
headers: {
DeviceAuthorization: DeviceAuthorization,
deviceId: deviceId,
'x-api-key': xApiKey,
},
})
.then(response => {
const result = response.data.recent_articles
result.forEach(async element => {
//for each identifier make another request to delete the notification
axios
.delete(`${deleteWarning}/${element.id}`, {
headers: {
AUTHORIZATION: `Bearer ${bearerToken}`,
},
})
.then(response => {
console.log(`status code: ${response.status}`)
})
.catch(error => {
console.log(error)
})
})
})
.catch(error => {
console.log(`get warnings error: ${error}`)
})