In the previous section, we talked about how to package JSONP
This section obtains the data of Tencent Music on the basis of the previous section.
First of all:
What is config.js in the figure above? Very simple: is QQ music invariable some parameters. Separate out is convenient for later call: as follows
The above concerns the assign method:
Object.assign({}, commonParams, {
platform: 'h5'.uin: 0.needNewCode: 1
})
Copy the code
The Object.assign method is used to merge objects. It copies all the enumerable attributes of the source Object to the target Object.
The first {} in the method is the target object.
The combined results of the above methods are:
Finally, get the data: