Comments (6)
没收到类似问题。请求拦截器和响应拦截器是一样的。
from luch-request.
请求拦截器也是不生效的,今天我试过发现请求拦截器的token在nvue页面也没有加载到,后来我改用vuex 在vuex中使用,在vuex中发送请求这样是可以的
from luch-request.
是不是用了什么在nvue 里不能用的api
from luch-request.
我有开了一个新项目,使用了拦截器,创建nvue页面请求并打印数据
在h5页面数据为(此时拦截器生效)
在App端打印的数据为(此时拦截器并未生效)
当我把页面改为vue页面后,重新运行发现App端拦截器又生效了
所以应该是不支持nvue页面请求的~
from luch-request.
我在模拟器跑了一个demo,页面也是nvue的,是可以应用拦截器的。
import Request from 'luch-request'
const http = new Request({
baseURL: ''
})
http.setConfig((config) => { /* 设置全局配置 */
config.baseURL = 'https://www.fastmock.site/mock/26243bdf9062eeae2848fc67603bda2d/luchrequest'
config.header = {
...config.header,
a: 1, // 演示
b: 2 // 演示
}
config.custom = {
// auth: false, // 是否传token
// loading: false // 是否使用loading
}
return config
})
http.interceptors.request.use(config => {
console.log(config);
config.header.aaaaaaaaaaa =2
return config
})
http.interceptors.response.use(res => {
res.data.bbbbbbbbb = 2
return res
})
export {
http
}
import {http} from '../service/request.js'
export default {
updateUser: (data) => http.post('/api/user/update', data)
}
<template>
<view class="content">
<button @click="getUser">请求</button>
</view>
</template>
<script>
import api from '@/api/index.js';
export default {
data() {
return {
title: 'Hello'
};
},
onLoad() {},
methods: {
getUser() {
api
.updateUser({
id: 2
})
.then(res => {
console.log('局部res', res);
}).catch(err => {
console.log('局部err', err);
});
}
}
};
</script>
<style>
</style>
from luch-request.
我今天把我的demo重新跑了一遍,发现又没问题了 麻了
from luch-request.
Related Issues (20)
- 我有一个接口对接了chatgpt,数据是流式返回的,如何能流式的取数据? HOT 4
- 没有 PATCH请求方式吗 ? HOT 2
- 支持 async、await 嘛 HOT 1
- node版本限制应是大于等于16,而非16吧,否则node18会无法安装 HOT 4
- 如何去掉Get请求头的content-type属性 HOT 1
- 请问有没有遇到过这个问题,new这个类,直接使用request.delete会说is not a function?如果是request.get或者post或者put都正常,唯独delete有问题 HOT 2
- validateStatus设置无效 HOT 3
- 麻烦看一下custom无法定义类型这个问题 HOT 1
- 上传多个文件时files参数怎么传?服务器端收到的ContentType为何是text/html HOT 2
- 关于vue.config.js中transpileDependencies配置问题 HOT 3
- 可以考虑封装一个useRequest uniapp版本的
- get请求可以禁止302重定向吗
- http.upload('api/upload/img', ;这个怎么用?method是upload? HOT 6
- http.upload('api/upload/img', ;这个怎么用?method是upload? HOT 2
- ios17.2.1 调用接口一直在加载中 HOT 2
- forcedJSONParsing 没有类型提示呀
- 微信小程序调用没有反应,基础库3.3.3
- 【BUG】设置请求超时 timeout 没有效果 HOT 5
- 怎么进行流式内容的获取? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luch-request.