I've this code below:

jQuery(document).ready(function() {

                    url: "https://test.sharepoint.com/sites/test/Negocio/_api/web/folders('Historico')/folders?$select=ID,Title,Created,Name",
                    type: "GET",
                    headers: {
                        "accept": "application/json;odata=verbose",
                        "content-type": "application/json;odata=verbose",

                    success: onQuerySucceeded,
                    error: onQueryFailed


            function onQuerySucceeded(data) 
                var dataresult = data.d.results;
                dataresult = [].slice.call(dataresult);
                dataresult.forEach(function(key, value){



            function onQueryFailed() {
                alert('Sorry An Error Has Occurred!');

Return this:

enter image description here

How can I retrieve the Name?

  • 1
    it should be key.Name in the foreach loop – Gautam Sheth Jan 17 '19 at 9:55
  • great, have posted that as answer :) You can accept it which will help us remove it from list of unanswered questions. Thanks & cheers ! – Gautam Sheth Jan 17 '19 at 10:06
  • 1
    Also, that undefined at the bottom is likely nothing to do with your API call. Chrome just does this in the console. So what you're seeing is the initial console.log of your entire dataset, then Chrome's confusing undefined. – AtariPixel Jan 17 '19 at 10:11

You need to modify the code as below:

dataresult.forEach(function(key, value){    

Here, key represents the element in the array and value here represents index.

Reference - Array forEach


Since you're already loading jQuery, you can shorten your success function to this.

function onQuerySucceeded(data) {
    $.each(data.d.results, function (key, value) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.