Skip to content

Commit

Permalink
fix(api-gateway): Unexpected token u in JSON at position 0 at JSON.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed May 31, 2019
1 parent 1740bc8 commit 91ca994
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cubejs-api-gateway/index.js
Expand Up @@ -230,6 +230,9 @@ class ApiGateway {
initApp(app) {
app.get(`${this.basePath}/v1/load`, this.checkAuthMiddleware, (async (req, res) => {
try {
if (!req.query.query) {
throw new UserError(`query param is required`);
}
const query = JSON.parse(req.query.query);
this.log(req, {
type: 'Load Request',
Expand Down Expand Up @@ -273,6 +276,9 @@ class ApiGateway {

app.get(`${this.basePath}/v1/sql`, this.checkAuthMiddleware, (async (req, res) => {
try {
if (!req.query.query) {
throw new UserError(`query param is required`);
}
const query = JSON.parse(req.query.query);
const normalizedQuery = normalizeQuery(query);
const sqlQuery = await this.getCompilerApi(req).getSql(coerceForSqlQuery(normalizedQuery, req));
Expand Down

0 comments on commit 91ca994

Please sign in to comment.