Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dotenv.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# See README.md for instructions on setting up the .env file
#
RKS_PROJECT_ID=

RKS_SERVICE_ACCOUNT=

# You can use \n to separate the lines in your private key
RKS_PRIVATE_KEY=
RKS_PRIVATE_KEY=
11 changes: 6 additions & 5 deletions quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ async function getServiceAccessToken() {
}


async function getFromApi(serviceAccessToken, resourceUrl, queryParams = {}, raiseError = true) {
async function getFromApi(serviceAccessToken, resourceUrl, queryParams = null, raiseError = true) {

const url = `${baseUrl}${resourceUrl}`
const queryString = queryParams ? `?${new URLSearchParams(queryParams)}` : '';
const url = `${baseUrl}${resourceUrl}${queryString}`;

const response = await fetch(url, {
headers: {
"Authorization": `Bearer ${serviceAccessToken}`,
"Accept": "application/json",
"Content-Type": "application/json; charset=utf-8"
},
queryParams: queryParams,
}
});

if (!response.ok && raiseError) {
Expand Down Expand Up @@ -122,7 +123,7 @@ async function quickstart() {

if (participantIdentifier != "YOUR_PARTICIPANT_IDENTIFIER") {
url = `/api/v1/administration/projects/${rksProjectId}/participants/${participantIdentifier}`;
response = await getFromApi(serviceAccessToken, url, {}, false );
response = await getFromApi(serviceAccessToken, url, null, false );
if (response.status === 404) {
console.log("\nParticipant not found.");
} else {
Expand Down
Loading