Created
July 5, 2016 10:43
-
-
Save roobie/93b89b7727db89b6fe5caee54b9ef0fa to your computer and use it in GitHub Desktop.
en möjlig lösning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| console.clear(); | |
| var get = function (url) { | |
| return $.ajax({ | |
| url: url, | |
| type: "GET", | |
| headers: { "accept": "application/json;odata=verbose" } | |
| }); | |
| }; | |
| get("/_api/sp.userprofiles.peoplemanager/getmyproperties?$select=Email") | |
| .then(function getEmail(data) { | |
| return data.d.Email; | |
| }) | |
| .then(function getIsEditorOfAsync(name) { | |
| return get("/_api/search/query?querytext='EditorOWSUSER:%NAME'".replace('%NAME', name)); | |
| }) | |
| .then(function extractRelevantResults(data) { | |
| return data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results; | |
| }) | |
| .then(function makeHashMaps(rows) { | |
| var cellsToHashMap = function (cells) { | |
| return cells.reduce(function (out, kvp) { | |
| out[kvp.Key] = kvp.Value; | |
| return out; | |
| }, {}); | |
| }; | |
| return rows.map(function (row) { | |
| var cells = row.Cells.results; | |
| return cellsToHashMap(cells); | |
| }); | |
| }) | |
| .then(console.log.bind(console)); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment