Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function func1(typeid) {
- getTypes(typeid).then(function (responseData) { //getTypes returns all the child types of a given parent typeid
- var types = JSON.parse(responseData);
- AuthClient.credentials.getToken()
- .then(function (token) {
- types.forEach(function (element) {
- var options = {
- method: 'POST',
- url: url,
- qs: {
- access_token: token.accessToken
- },
- headers: {
- 'content-type': 'application/json'
- },
- body: element,
- json: true
- }
- request(options, function (error, response, body) {
- if (error) throw new Error(error)
- if (response.statuscode === 200) {
- func1(element.id);
- console.log(body);
- }
- });
- });
- })
- .catch(function (err) {
- console.log(err);
- });
- });
- }
- func1(roottypeid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement