I start with Node. Sorry for what is probably a stupid question.
Trying to understand why the code below causes an error: ReferenceError: Promise not defined
allAccountFixtures: ['account-customer-joe', 'account-partner-sam', 'account-partner-jane', 'account-admin-jill'],
allProductFixtures: ['product-123', 'product-234', 'product-345', 'product-456'],
...
loadBasicFixtures: (Api) => {
return Promise.all([
Support.importRecords(Api.accountsAPI, Support.allAccountFixtures),
Support.importRecords(Api.productsAPI, Support.allProductFixtures)
]);
},
My APIs are defined elsewhere:
this.accountsAPI = app.service('/api/accounts');
this.productsAPI = app.service('/api/products');
Import function:
importRecords: (feathersService, fixtureNames) => {
if (!(fixtureNames instanceof Array)) { fixtureNames = [fixtureNames]; }
var promises = fixtureNames.map(fixtureName => {
var filePath = `test/fixtures/json/${fixtureName}.json`;
return fs.readFileAsync(filePath, 'utf8')
.then((jsonString) => {
return JSON.parse(jsonString);
}).then((json) => {
return feathersService.create(json);
});
});
return Promise.all(promises);
},
I do not know if the information provided is enough to tell what is happening. I took a look at the concept of "promise" and that is pretty much. Perhaps you could point in the right direction. The documentation mentions permission and rejection.
source
share