Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. function func1(typeid) {
  2. getTypes(typeid).then(function (responseData) { //getTypes returns all the child types of a given parent typeid
  3. var types = JSON.parse(responseData);
  4.  
  5. AuthClient.credentials.getToken()
  6. .then(function (token) {
  7. types.forEach(function (element) {
  8.  
  9. var options = {
  10. method: 'POST',
  11. url: url,
  12. qs: {
  13. access_token: token.accessToken
  14. },
  15. headers: {
  16. 'content-type': 'application/json'
  17. },
  18. body: element,
  19. json: true
  20. }
  21. request(options, function (error, response, body) {
  22. if (error) throw new Error(error)
  23. if (response.statuscode === 200) {
  24. func1(element.id);
  25. console.log(body);
  26. }
  27. });
  28. });
  29. })
  30. .catch(function (err) {
  31. console.log(err);
  32. });
  33. });
  34. }
  35.  
  36. func1(roottypeid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement