I’m having trouble connecting to an API when I run node server.js on terminal.
My friend is running the same code as me but he is able connect.
Here is the SyntaxError:
SyntaxError: Invalid or unexpected token
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:139:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:236:14)
at async link (node:internal/modules/esm/module_job:67:21)
Appartently the error is in the last line of code:
const OMIE_APP_KEY = ""
const OMIE_APP_SECRET = ""
const api = axios.create({
baseURL: "https://app.omie.com.br/api/v1/produtos/requisicaocompra/",
});
const app = express()
const server = http.createServer(app)
const sockets = new Server(server)
let data = schema.data
mongoose.connect('mongodb://localhost/aluno_teste') //conexão com o banco de dados
mongoose.connection
.once('open', () => console.log('Conexao com MongoDB (banco de dados) foi estabelecida com sucesso'))
.on('error', (error) => {
console.warn('Falha ao se conectar com o banco de dados. Motivo: ', error)
})
app.use(express.static('public2'))//torna pública a pasta 'public2' para quem tiver acesso ao "port" exposto pelo server
sockets.on('connection', async (socket) => {
socket.on('IncluirProduto', async (obj) => {
//let a = await data.findOne({})
if(0 == 1){
async function incluirPedido() {
try {
const response = await api.post('/', {call:"IncluirProduto",app_key:OMIE_APP_KEY,app_secret:OMIE_APP_SECRET,param:[{
For more information, here is the Code
Thanks in advance!