Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_data(url) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
- try {
- xhr.setRequestHeader('X-XSRF-TOKEN', 'iYQml0FRdtzo5gnIIZOur59/HjaKG0azoODhOpKLXt9uZxAB+ixTqXA2tBHU7MNofgpmFG2OdtyWTnMoCr3PJg==');
- } catch (e) {};
- try {
- xhr.setRequestHeader('Accept-Language', 'en-us');
- } catch (e) {};
- try {
- xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
- } catch (e) {};
- xhr.withCredentials = true;
- xhr.onerror = function(e) {
- };
- xhr.onload = function(e) {
- load_data(url,xhr.responseText)
- }
- xhr.send('');
- }
- function load_data(url, response) {
- $.post( "url_send", { content: response, url: url })
- .done(function( data_andwer ) {
- });
- var jsonResponse = JSON.parse(response);
- if(url.indexOf('SystemGroups')>0) {
- console.log(url);
- }else if(url.indexOf('subcategories')>0) {
- for (data in jsonResponse.systemGroups) {
- var systemGroups = jsonResponse.systemGroups[data];
- url = 'https://epc.teslamotors.com/api/SystemGroups/'+systemGroups['id']+'?vin=';
- get_data(url);
- }
- }else if(url.indexOf('Categories')>0) {
- for (data in jsonResponse) {
- var subcat = jsonResponse[data]['subcategories'];
- for (sub_data in subcat) {
- url = 'https://epc.teslamotors.com/api/Categories/24/subcategories/'+subcat[sub_data]['id'];
- get_data(url);
- }
- }
- }
- }
- get_data('https://epc.teslamotors.com/api/model3/Categories');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement