musixmatch / musixmatch-sdk

Musixmatch OpenAPI - Swagger SDK clients
MIT License
93 stars 39 forks source link

webpack integration #1

Open Bek81 opened 6 years ago

Bek81 commented 6 years ago

Hi, I'm developing a webpack project and I would like to be able to integrate Musixmatch Api. Can you tell me the right procedure or at least explain how to add it simply as a library in my index?

Thanks and regards.

Bek81 commented 6 years ago

Hi,

after the build using "javascript-client-patch.zip", i copied the bundle.js generated in my project file "libs/musixmatchapi/index.js" and then I imported that in my HTML:

. Seems to be loaded correctly. In my JS, I tried (with my own API KEY), following your example: ``` let defaultClient = MusixmatchApi.ApiClient.instance; console.log(defaultClient); let key = defaultClient.authentications['key']; console.log(key); key.apiKey = "25bf7fc9ee28d0208d75d522c56e1422"; var opts = { format: "jsonp", // {String} output format: json, jsonp, xml. }; let trackId= 15449912; // {number} (new MusixmatchApi.TrackApi()).trackGetGet(trackId, opts, (error, data, response) => { if (error) { console.error(error); } else if(response.text) { data = JSON.parse(response.text); console.log('Returned data:\n%s' ,JSON.stringify(data,null,2)); } else { throw new Error('bad response') } } ); ``` and these are the responses: screen shot 2018-07-25 at 11 35 59 If I try ` format: "json"` the response is cross origin. Another question: where do I find the documentation for these APIs? For the other methods apart from "trackGetGet"?