Closed DiffYao closed 2 years ago
Hi Diffyao,
It seems like the SAFE does not support the keyword "let". If you change the let to var, it may solve the issue, but there may be some other syntax issues that SAFE cannot handle. I also have those issues when I try to use SAFE on the "aws-lambda".
Hi @jhnaldo , I was also wondering why SAFE will have such an issue. I briefly review the code, and the error messages seem like about the square brackets "[". Whether you can provide us with some suggestions about how to solve the issue? or whether we can ignore the issues and make SAFE skip those lines that it cannot handle.
Best, Yichao.
Hi @DiffYao and @YichaoXu, SAFE only supports JavaScript language features defined in ES5.1. So, the JavaScript parser used in SAFE does not support ES6+ features, such as let
binding you mentioned. We do not have a plan to support such features in SAFE, but you can desugar ES6+ features to ES5.1 features using Babel before analyzing JavaScript code.
Hi Jhnaldo, thank you a lot for your reply. That's helpful.
Best, Yichao
Thanks for your reply!
My Program
import fetch from "node-fetch";
// Plain text or HTML let response = await fetch("https://github.com/"); let body = await response.text();
console.log(body);
// JSON response = await fetch("https://github.com/"); json = await response.json();
console.log(json);
// Simple Post response = await fetch("https://httpbin.org/post", { method: "POST", body: "a=1", }); json = await response.json();
console.log(json);
// Post with JSON body = { a: 1 };
response = await fetch("https://httpbin.org/post", { method: "post", body: JSON.stringify(body), headers: { "Content-Type": "application/json" }, }); const json = await response.json();
console.log(json);