Set token for project metadata request

This commit is contained in:
rschamp 2022-05-06 14:13:55 -04:00
parent 6f457ff1da
commit 8b4c692e33
2 changed files with 11 additions and 1 deletions

View file

@ -11,9 +11,18 @@ class Storage extends ScratchStorage {
super(); super();
this.addWebSource( this.addWebSource(
[this.AssetType.Project], [this.AssetType.Project],
projectAsset => `${PROJECT_HOST}/${projectAsset.assetId}` this.getProjectGetConfig.bind(this)
); );
} }
setProjectToken (projectToken) {
this.projectToken = projectToken;
}
getProjectGetConfig (projectAsset) {
const path = `${PROJECT_HOST}/${projectAsset.assetId}`;
const qs = this.projectToken ? `?token=${this.projectToken}` : '';
return path + qs;
}
} }
const storage = new Storage(); const storage = new Storage();

View file

@ -159,6 +159,7 @@ class Preview extends React.Component {
} }
} }
if (this.props.projectInfo.id !== prevProps.projectInfo.id) { if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
storage.setProjectToken(this.props.projectInfo.project_token);
if (typeof this.props.projectInfo.id === 'undefined') { if (typeof this.props.projectInfo.id === 'undefined') {
this.initCounts(0, 0); this.initCounts(0, 0);
} else { } else {