Skip to content

Commit fd7b35d

Browse files
committed
Merge pull request #1113 from DelvarWorld/api-client-not-defined
Fixing "_ApiClient is not defined" by adding empty class method to ApiClient
2 parents d4d38aa + be090cf commit fd7b35d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/helpers/ApiClient.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ function formatUrl(path) {
1313
return '/api' + adjustedPath;
1414
}
1515

16-
/*
17-
* This silly underscore is here to avoid a mysterious "ReferenceError: ApiClient is not defined" error.
18-
* See Issue #14. https://github.com/erikras/react-redux-universal-hot-example/issues/14
19-
*
20-
* Remove it at your own risk.
21-
*/
22-
class _ApiClient {
16+
export default class ApiClient {
2317
constructor(req) {
2418
methods.forEach((method) =>
2519
this[method] = (path, { params, data } = {}) => new Promise((resolve, reject) => {
@@ -40,8 +34,15 @@ class _ApiClient {
4034
request.end((err, { body } = {}) => err ? reject(body || err) : resolve(body));
4135
}));
4236
}
37+
/*
38+
* There's a V8 bug where, when using Babel, exporting classes with only
39+
* constructors sometimes fails. Until it's patched, this is a solution to
40+
* "ApiClient is not defined" from issue #14.
41+
* https://github.com/erikras/react-redux-universal-hot-example/issues/14
42+
*
43+
* Relevant Babel bug (but they claim it's V8): https://phabricator.babeljs.io/T2455
44+
*
45+
* Remove it at your own risk.
46+
*/
47+
empty() {}
4348
}
44-
45-
const ApiClient = _ApiClient;
46-
47-
export default ApiClient;

0 commit comments

Comments
 (0)