没封装前可以返回数据:
axios({
url: `https://m.maizuo.com/gateway?filmId=${this.$route.params.id}&k=930931`,
headers: {
'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"16466636386676260373659649","bc":"110100"}',
'X-Host': 'mall.film-ticket.film.info'
}
}).then(res => {
console.log(res)
this.filmInfo = res.data.data.film
})
封装后就无法返回数据了:
http({
url: `/gateway?filmId=${this.$route.params.id}&k=930931`,
headers: {
'X-Host': 'mall.film-ticket.film.info'
}
}).then(res => {
console.log(res.data.data.films)
this.datalist = res.data.data.film
})
这是封装的axios:
import axios from 'axios'
const http = axios.create({
baseURL: 'https://m.maizuo.com',
timeout: 1000,
headers: {
'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"16466636386676260373659649"}'
}
})
控制台结果就只有:
undefined