Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
Project Page
Commits
a004cf5b
Commit
a004cf5b
authored
Jul 30, 2020
by
Rosanny Sihombing
Browse files
call projects API in a loop
parent
d992c475
Changes
1
Hide whitespace changes
Inline
Side-by-side
routes/routes-project.js
View file @
a004cf5b
...
...
@@ -362,30 +362,40 @@ module.exports = function (app) {
app
.
get
(
'
/projectlist
'
,
async
function
(
req
,
res
){
let
projectArr
=
[]
let
marker
=
fals
e
let
isProject
=
tru
e
let
firstId
=
0
/*
while (
marker == fals
e) {
while
(
isProject
==
tru
e
)
{
let
projects
=
await
getProjectsFromGitlab
(
10
,
firstId
)
let
projectData
=
projects
.
data
for(let i = 0; i < projectData.length; i++){
console.log(projectData[i].name)
if (projectData[i].avatar_url == null) {
projectData[i].avatar_url = "https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png"
}
let project = {
logo: projectData[i].avatar_url,
name: projectData[i].name,
weburl: projectData[i].web_url,
desc: projectData[i].description
}
projectArr.push(project)
if
(
projectData
.
length
==
0
)
{
isProject
=
false
}
else
{
for
(
let
i
=
0
;
i
<
projectData
.
length
;
i
++
){
console
.
log
(
projectData
[
i
].
id
)
if
(
projectData
[
i
].
avatar_url
==
null
)
{
projectData
[
i
].
avatar_url
=
"
https://m4lab.hft-stuttgart.de/img/footer/M4_LAB_LOGO_Graustufen.png
"
}
let
project
=
{
logo
:
projectData
[
i
].
avatar_url
,
name
:
projectData
[
i
].
name
,
weburl
:
projectData
[
i
].
web_url
,
desc
:
projectData
[
i
].
description
}
projectArr
.
push
(
project
)
}
marker = true
firstId
=
projectData
[
projectData
.
length
-
1
].
id
console
.
log
(
'
firstId:
'
+
firstId
)
}
}
*/
res
.
render
(
lang
+
'
/project/projectList
'
,
{
project
:
projectArr
})
/*
let projects = await getProjectsFromGitlab(10, 0)
let projectData = projects.data
...
...
@@ -406,7 +416,7 @@ module.exports = function (app) {
res.render(lang+'/project/projectList', {
project: projectArr
})
*/
/*
request.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/projects?pagination=keyset&per_page=100&order_by=id&sort=asc&id_after='+firstId, function(error, response, body){
if(!error) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment