fix(code): move root init

Signed-off-by: Andrew Hill <andrew@textile.io>
This commit is contained in:
Andrew Hill 2020-09-22 15:19:44 -07:00
parent 12a77dfa88
commit bf70a7f182
No known key found for this signature in database
GPG Key ID: B8929C9860377979

View File

@ -127,6 +127,7 @@ export const getBucketAPIFromUserToken = async (token, user) => {
const identity = await PrivateKey.fromString(token);
const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
await buckets.getToken(identity);
let root
// TODO(jim): Put this call into a file for all Textile related calls.
console.log(`[buckets] getOrCreate`);
@ -151,7 +152,7 @@ export const getBucketAPIFromUserToken = async (token, user) => {
}
const roots = await buckets.list()
let root = roots.find((bucket) => bucket.name === BUCKET_NAME)
roots.find((bucket) => bucket.name === BUCKET_NAME)
if (!root) {
const created = await buckets.create(BUCKET_NAME)
root = created.root