First of all you need to create a personal access token:
Go to
profile
/preferences
/access tokens
or just click here
Repalce your token in token
variable in this code bellow:
const axios = require("axios");
// Your authorization token here
const token = "YOUR_ACCESS_TOKEN";
// fetch all projects
axios
.get("https://gitlab.com/api/v4/projects?visibility=private", {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then(async function (response) {
// get all projects IDs
let ids = response.data.map((e) => e.id);
// delete all
for (let el of ids) {
await axios.delete(`https://gitlab.com/api/v4/projects/${el}/`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
}
})
.catch(function (error) {
// handle error
console.log(error);
});
You can change the visibility ?visibility=private
or ?visibility=public