don't create unneeded variables

pull/988/head
Ryan Tharp 5 years ago
parent 4bb2e83cb3
commit d15445a1e0

@ -296,12 +296,11 @@ const serverRequest = async (endpoint, options = {}) => {
// if it's a response style with a meta // if it's a response style with a meta
if (result.status !== 200) { if (result.status !== 200) {
if (!forceFreshToken && (!response.meta || response.meta.code === 401)) { if (!forceFreshToken && (!response.meta || response.meta.code === 401)) {
// copy options because lint complains if we modify this directly // retry with forcing a fresh token
const updatedOptions = options; return this.serverRequest(endpoint, {
// force it this time ...options,
updatedOptions.forceFreshToken = true; forceFreshToken: true,
// retry with updated options });
return this.serverRequest(endpoint, updatedOptions);
} }
return { return {
err: 'statusCode', err: 'statusCode',
@ -690,14 +689,15 @@ class LokiAppDotNetServerAPI {
} }
// make a request to the server // make a request to the server
async serverRequest(endpoint, pOptions = {}) { async serverRequest(endpoint, options = {}) {
const options = pOptions;
options.token = this.token;
options.srvPubKey = this.pubKey;
if (options.forceFreshToken) { if (options.forceFreshToken) {
await this.getOrRefreshServerToken(true); await this.getOrRefreshServerToken(true);
} }
return serverRequest(`${this.baseServerUrl}/${endpoint}`, options); return serverRequest(`${this.baseServerUrl}/${endpoint}`, {
...options,
token: this.token,
srvPubKey: this.pubKey,
});
} }
async getUserAnnotations(pubKey) { async getUserAnnotations(pubKey) {

Loading…
Cancel
Save