updated requests to send token as header
This commit is contained in:
parent
3cbb59f16a
commit
4aaebef0e7
3 changed files with 12 additions and 12 deletions
|
@ -89,9 +89,8 @@ const getCollections = async (
|
|||
): Promise<collection[]> => {
|
||||
try {
|
||||
const resp = await HTTPService.get(`${ENDPOINT}/collections`, {
|
||||
token: token,
|
||||
sinceTime: sinceTime,
|
||||
});
|
||||
}, { 'X-Auth-Token': token, });
|
||||
const promises: Promise<collection>[] = resp.data.collections.map(
|
||||
(collection: collection) => getCollectionSecrets(collection, key)
|
||||
);
|
||||
|
@ -165,7 +164,7 @@ export const AddCollection = async (collectionName: string, type: CollectionType
|
|||
|
||||
const createCollection = async (collectionData: collection, token: string): Promise<collection> => {
|
||||
try {
|
||||
const response = await HTTPService.post(`${ENDPOINT}/collections`, collectionData, { token });
|
||||
const response = await HTTPService.post(`${ENDPOINT}/collections`, collectionData, null, { 'X-Auth-Token': token });
|
||||
return response.data.collection;
|
||||
} catch (e) {
|
||||
console.log("create Collection failed " + e);
|
||||
|
@ -207,7 +206,7 @@ const addtoCollection = async (collection: collection, files: file[]) => {
|
|||
})
|
||||
return file;
|
||||
}));
|
||||
await HTTPService.post(`${ENDPOINT}/collections/add-files`, params, { token });
|
||||
await HTTPService.post(`${ENDPOINT}/collections/add-files`, params, null, { 'X-Auth-Token': token });
|
||||
} catch (e) {
|
||||
console.log("Add to collection Failed " + e);
|
||||
}
|
||||
|
@ -223,7 +222,7 @@ const removeFromCollection = async (collection: collection, files: file[]) => {
|
|||
}
|
||||
params["fileIDs"].push(file.id);
|
||||
}));
|
||||
await HTTPService.post(`${ENDPOINT}/collections/remove-files`, params, { token });
|
||||
await HTTPService.post(`${ENDPOINT}/collections/remove-files`, params, null, { 'X-Auth-Token': token });
|
||||
} catch (e) {
|
||||
console.log("remove from collection failed " + e);
|
||||
}
|
||||
|
|
|
@ -110,9 +110,11 @@ export const getFiles = async (collections: collection[], sinceTime: string, lim
|
|||
resp = await HTTPService.get(`${ENDPOINT}/collections/diff`, {
|
||||
collectionID: collection.id,
|
||||
sinceTime: time,
|
||||
token,
|
||||
limit,
|
||||
});
|
||||
},
|
||||
{
|
||||
'X-Auth-Token': token
|
||||
});
|
||||
promises.push(...resp.data.diff.map(
|
||||
async (file: file) => {
|
||||
if (!file.isDeleted) {
|
||||
|
@ -148,8 +150,8 @@ export const getPreview = async (token: string, file: file) => {
|
|||
}
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/files/preview/${file.id}`,
|
||||
{ token },
|
||||
null,
|
||||
{ 'X-Auth-Token': token },
|
||||
{ responseType: 'arraybuffer' }
|
||||
);
|
||||
const worker = await new CryptoWorker();
|
||||
|
@ -173,8 +175,8 @@ export const getFile = async (token: string, file: file) => {
|
|||
try {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/files/download/${file.id}`,
|
||||
{ token },
|
||||
null,
|
||||
{ 'X-Auth-Token': token },
|
||||
{ responseType: 'arraybuffer' }
|
||||
);
|
||||
const worker = await new CryptoWorker();
|
||||
|
|
|
@ -261,7 +261,7 @@ class UploadService {
|
|||
|
||||
private async uploadFile(uploadFile: uploadFile, token) {
|
||||
try {
|
||||
const response = await HTTPService.post(`${ENDPOINT}/files`, uploadFile, { token });
|
||||
const response = await HTTPService.post(`${ENDPOINT}/files`, uploadFile, null, { 'X-Auth-Token': token });
|
||||
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
|
@ -404,9 +404,8 @@ class UploadService {
|
|||
if (!this.uploadURLFetchInProgress) {
|
||||
this.uploadURLFetchInProgress = HTTPService.get(`${ENDPOINT}/files/upload-urls`,
|
||||
{
|
||||
token: token,
|
||||
count: Math.min(50, count).toString() //m4gic number
|
||||
})
|
||||
}, { 'X-Auth-Token': token })
|
||||
const response = await this.uploadURLFetchInProgress;
|
||||
|
||||
this.uploadURLFetchInProgress = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue