【发布时间】:2018-05-15 11:36:32
【问题描述】:
我正在尝试使用 firebase-hosting 托管一个网站,但出现错误:
Uncaught SyntaxError: Unexpected identifier
它发生在script.js:1。源代码如下所示:
import axios from 'axios';
callWs();
console.log('This worked now!');
async function callWs() {
try {
const res = await axios(
`https://us-central1-jpabiggmbh-001.cloudfunctions.net/realexData?amt=${500}&curr=${'CHF'}`
);
console.log('This function ran just now!');
} catch (e) {
console.log(e);
}
console.log(res);
}
我的文件夹结构如下(关注公共树):
我正在调用index.html中的脚本:
<head>
<title>Fantastic title</title>
<script src="script.js"></script>
</head>
我的firebase-functions 导入工作正常,但我有一个package.json 文件,我认为这是我遇到问题的原因之一?
我的firebase.json 文件如下所示:
{
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
【问题讨论】:
标签: firebase google-cloud-functions importerror firebase-hosting