javascript - Vue.Js axios 获取请求未通过
问题描述
我正在尝试使用来自 vuex store.js 文件的 axios 发送获取请求, 当我在浏览器中搜索 api 时,我使用的 api 是https://openlibrary.org/dev/docs/api/search工作得很好,但是,当我使用我正在处理的应用程序使用 axios 发送请求时,它什么也没做。
这是store.js代码
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
export default new Vuex.Store({
state: {},
mutations: {},
actions: {
findBook({commit, dispatch}, book) {
console.log('logged before the request'); //this gets logged to the console
axios.get('http://openlibrary.org/search.json?title=the+lord+of+the+rings')
.then(res => {
console.log(`logged after the request`); //this doesn't get logged
console.log(res);
}).catch(err => console.log(err))
}
}
})
此外,我从 catch 块中完全没有错误,
有人能告诉我我在这里想念什么吗?提前致谢。
解决方案
推荐阅读
- java - 为什么我的线程在调用服务方法时阻塞
- react-native - undefined is not an object(evalating 'this.localStorage.getItem') react-native中的错误
- typescript - 尝试发送消息时出现错误“Office.context.ui.messageParent 不是函数”
- spring - Spring Integration 重试建议配置
- c# - 从 GitHub(PowerShell 或 .net)上的私有仓库下载资产
- firebase - 颤振和火力| 我正在尝试为没有帐户的用户显示一个snackBar,但它显示在我的终端“[firebase_auth/user-not-found]”中
- html - 用浮动包装文本:权利不适用于 itch.io
- shell - 如何在 xonsh 子进程中扩展 shell 变量?
- node.js - 与 api 端点一起使用时,快速 glob 同步返回空数组
- javascript - 为什么我在 ASP.Net 中的cropper.js 文件上收到 404 错误,尽管它们正是程序正在寻找它们的位置?