我正在尝试从旅行站点检索所有可用目的地的列表,然后使用它执行某些任务。我需要使用axios,我通过npm安装了它,然后在index.html中做到了:
<script>
var App = App || {};
App.THEME_URL = "http://staging.earthviaggi-
stage.com/themes/custom/earthviaggi";
App.IMGS_URL = "http://staging.earthviaggi-stage.com/themes/custom/earthviaggi/assets/imgs";
App.ASSETS_URL = "http://staging.earthviaggi- stage.com/themes/custom/earthviaggi/assets";
App.BASE_URL = "http://staging.earthviaggi-stage.com";
App.BASE_URL_LANG = "http://staging.earthviaggi-stage.com";
App.BASE_URL_CONTACTS = "http://staging.earthviaggi-stage.com/api/contact";
App.APP_ROOT = "/it";
App.CURRENT_ALIAS = "/earth-viaggi-tour-operator";
App.ASSETS_IMGS_URL = "http://staging.earthviaggi-stage.com/themes/custom/earthviaggi/assets/imgs";
App.LANG = "it";
App.MAIN_NAV_STATUS = "";
App.PAGE_ID = "home";
</script>
在我的 JS 文件中,我这样做:
import axios from 'axios';
export default {
async get() {
try {
const results = await axios.get(
`${App.BASE_URL_LANG}/api/game/destinations`
);
console.log(results);
return results;
} catch (error) {
console.log(error);
return null;
}
}
};
我没有得到任何回报。
我想念什么?我以前从未使用过axios。