Skip to main content
deleted 6 characters in body
Source Link
console.clear();
function get(uri,title) {
    if (typeof uri === 'object') uri = uri.__deferred.uri;
    fetch(uri, {
        method: 'GET',
        credentials: 'same-origin',    // or credentials: 'include'         
        headers: new Headers({
            "Accept": "application/json; odata=verbose",
        })
    }).then((response) => response.json())
        .then((data) => {
             console.info(title,data.d);
            (data.d.results || [data.d]).forEach((item) => {
                switch (item.__metadata.type) {
                    case 'SP.Web':
                        get(item.Lists,'Lists in Web: '+item.Title);
                        break;
                    case 'SP.List':
                        if(item.Title==='Tasks'){
                            get(item.Items,'Items in List: '+item.Title);
                        }
                        break;
                    default:
                        console.log('unknown type', item.__metadata.type);
                }
            });
        });
}
get('/sites/[YOURSITENAME]/_api/Web','Root');
console.clear();
function get(uri,title) {
    if (typeof uri === 'object') uri = uri.__deferred.uri;
    fetch(uri, {
        method: 'GET',
        credentials: 'same-origin',    // or credentials: 'include'         
        headers: new Headers({
            "Accept": "application/json; odata=verbose",
        })
    }).then((response) => response.json())
        .then((data) => {
             console.info(title,data.d);
            (data.d.results || [data.d]).forEach((item) => {
                switch (item.__metadata.type) {
                    case 'SP.Web':
                        get(item.Lists,'Lists in Web: '+item.Title);
                        break;
                    case 'SP.List':
                        if(item.Title==='Tasks'){
                            get(item.Items,'Items in List: '+item.Title);
                        }
                        break;
                    default:
                        console.log('unknown type', item.__metadata.type);
                }
            });
        });
}
get('/sites/[YOURSITENAME]/_api/Web','Root');
console.clear();
function get(uri,title) {
    if (typeof uri === 'object') uri = uri.__deferred.uri;
    fetch(uri, {
        method: 'GET',
        credentials: 'same-origin',    // or credentials: 'include'         
        headers: new Headers({
            "Accept": "application/json; odata=verbose",
        })
    }).then(response => response.json())
        .then(data => {
             console.info(title,data.d);
            (data.d.results || [data.d]).forEach(item => {
                switch (item.__metadata.type) {
                    case 'SP.Web':
                        get(item.Lists,'Lists in Web: '+item.Title);
                        break;
                    case 'SP.List':
                        if(item.Title==='Tasks'){
                            get(item.Items,'Items in List: '+item.Title);
                        }
                        break;
                    default:
                        console.log('unknown type', item.__metadata.type);
                }
            });
        });
}
get('/sites/[YOURSITENAME]/_api/Web','Root');
added 1420 characters in body
Source Link

#Update 2

To get you started with REST and Promises (the fetch API needs a Polyfill in IE!)

This dives into a site and all subwebs/lists/items:

console.clear();
function get(uri,title) {
    if (typeof uri === 'object') uri = uri.__deferred.uri;
    fetch(uri, {
        method: 'GET',
        credentials: 'same-origin',    // or credentials: 'include'         
        headers: new Headers({
            "Accept": "application/json; odata=verbose",
        })
    }).then((response) => response.json())
        .then((data) => {
             console.info(title,data.d);
            (data.d.results || [data.d]).forEach((item) => {
                switch (item.__metadata.type) {
                    case 'SP.Web':
                        get(item.Lists,'Lists in Web: '+item.Title);
                        break;
                    case 'SP.List':
                        if(item.Title==='Tasks'){
                            get(item.Items,'Items in List: '+item.Title);
                        }
                        break;
                    default:
                        console.log('unknown type', item.__metadata.type);
                }
            });
        });
}
get('/sites/[YOURSITENAME]/_api/Web','Root');

[iREST](https://sharepoint.stackexchange.com/search?q=iREST)- [iJS](https://sharepoint.stackexchange.com/search?q=iJS)

#Update 2

To get you started with REST and Promises (the fetch API needs a Polyfill in IE!)

This dives into a site and all subwebs/lists/items:

console.clear();
function get(uri,title) {
    if (typeof uri === 'object') uri = uri.__deferred.uri;
    fetch(uri, {
        method: 'GET',
        credentials: 'same-origin',    // or credentials: 'include'         
        headers: new Headers({
            "Accept": "application/json; odata=verbose",
        })
    }).then((response) => response.json())
        .then((data) => {
             console.info(title,data.d);
            (data.d.results || [data.d]).forEach((item) => {
                switch (item.__metadata.type) {
                    case 'SP.Web':
                        get(item.Lists,'Lists in Web: '+item.Title);
                        break;
                    case 'SP.List':
                        if(item.Title==='Tasks'){
                            get(item.Items,'Items in List: '+item.Title);
                        }
                        break;
                    default:
                        console.log('unknown type', item.__metadata.type);
                }
            });
        });
}
get('/sites/[YOURSITENAME]/_api/Web','Root');

[iREST](https://sharepoint.stackexchange.com/search?q=iREST)- [iJS](https://sharepoint.stackexchange.com/search?q=iJS)
added 2484 characters in body
Source Link

Notes

You are now missing the 'Documents' Library in the rootWeb itself

ideally the 2 functions should be merged into one inspectWeb( url ) function, If this===window you know it was NOT called from an async function

Then add a recursive call to dive into all subwebs

Notes

You are now missing the 'Documents' Library in the rootWeb itself

ideally the 2 functions should be merged into one inspectWeb( url ) function, If this===window you know it was NOT called from an async function

Then add a recursive call to dive into all subwebs

added 2484 characters in body
Source Link
Loading
added 2484 characters in body
Source Link
Loading
Source Link
Loading