Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
happy-botday
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume Vagner
happy-botday
Commits
08d3442c
Commit
08d3442c
authored
6 years ago
by
Guillaume Vagner
Browse files
Options
Downloads
Patches
Plain Diff
commentage de requests.js
parent
cab48fef
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
requests.js
+5
-6
5 additions, 6 deletions
requests.js
with
5 additions
and
6 deletions
requests.js
+
5
−
6
View file @
08d3442c
const
rp
=
require
(
'
request-promise
'
);
const
Channel
=
require
(
'
./models/Channel
'
);
function
sendRequest
(
req
,
token
)
{
// Fonction d'envoi d'une requête au GraphQL de LinkCS
async
function
sendRequest
(
req
,
token
)
{
const
options
=
{
headers
:
{
'
Authorization
'
:
`Bearer
${
token
}
`
},
json
:
true
...
...
@@ -13,7 +11,7 @@ function sendRequest(req, token) {
return
rp
(
`
${
url
}
?query=
${
req
}
`
,
options
)
}
// Récupération de tous les personnes et leurs assos ayant leur anniversaire
function
getBirthdays
(
token
)
{
const
req
=
'
query getUsersBirthday {users: usersBirthday { ...userData}}fragment userData on User {id firstName lastName roles {sector {composition {association {id}}}}}
'
return
sendRequest
(
req
,
token
).
then
(
body
=>
{
...
...
@@ -31,7 +29,7 @@ function getBirthdays(token) {
})
}
// Récupération de la recherche de groupe
function
searchGroups
(
token
,
term
)
{
const
req
=
`query {searchAssociations(term: "
${
term
}
") {id name code}}`
return
sendRequest
(
req
,
token
).
then
(
body
=>
{
...
...
@@ -40,6 +38,7 @@ function searchGroups(token, term) {
}).
catch
(
err
=>
{
console
.
error
(
err
)
})
}
// Récupération du nom de l'asso ayant l'ID donnée
function
getGroupById
(
token
,
id
)
{
const
req
=
`query {association(id:
${
id
}
) {name}}`
return
sendRequest
(
req
,
token
).
then
(
body
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment