请问apiStack里面的字符串怎么提取出来使用,能否提供一个完整的流程?
product的代码。请问哪里需要修改
import jsonp from 'assets/js/jsonp';
import {jsonpOptions} from './config';
//获取商品详情页数据 -- jsonp
export const getProductDetail = id => {
// console.log(id);
const url = 'https://unszacs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/';
const params = {
api: 'mtop.taobao.detial.getdetail',
ttid: '2017@taobao_h56.6.0',
data: `{"itemNumId":"${id}"}`,
appKey: 12574478,
dataType: 'jsonp',
type: 'jsonp',
v:'6.0'
};
return jsonp(url, params, jsonpOptions).then(res => {
if (res) {
return res;
}
throw new Error('没有成功获取到数据!');
}).catch(err => {
if (err) {
console.log(err);
}
}).then(res => {
return new Promise(resolve => {
setTimeout(() => {
resolve(res);
}, 1000);
});
});
};
正在回答
同学你好,可以使用JSON.parse()方法。
可参考代码:
效果:
祝学习愉快~
- 参与学习 人
- 提交作业 239 份
- 解答问题 10739 个
本阶段带你深入前端开发的肌理,通过ES6基础知识和前端主流高级框架的学习,助你快速构建企业级移动webAPP应用,进入职场的终极battle
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星