Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Authenticate on lesson title fetch #487

Merged
merged 1 commit into from
Jun 13, 2017
Merged
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
6 changes: 5 additions & 1 deletion lib/notifications/submission.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use babel'

import path from 'path'
import token from '../token'
import fetch from '../fetch'
import {learnCo} from '../config'

Expand All @@ -12,7 +13,10 @@ function getLessonTitle(lessonID) {

if (title != null) { return Promise.resolve(title) }

return fetch(`${learnCo}/api/v1/lessons/${lessonID}`).then(({title}) => {
var lessonEndpoint = `${learnCo}/api/v1/lessons/${lessonID}`;
var headers = new Headers({'Authorization': `Bearer ${token.get()}`});

return fetch(lessonEndpoint, {headers}).then(({title}) => {
cachedLessonTitles[lessonID] = title || 'Learn IDE';
return title;
});
Expand Down