Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function guaranteedPost(endpointId, wallPost, attempts){
- var attempts = attempts || 0
- return graph.postAsync(endpointId + '/feed', wallPost)
- .then(function(response){
- return response
- })
- .catch(function(error){
- if(error.message != errorMessage){
- return Promise.reject(error.message)
- }
- console.log('Retry attempt #: ' + attempts)
- if(attempts == 5){
- return Promise.reject('Too many errors')
- }
- // console.log(error)
- return Promise.delay(5000).then(function(){
- return guaranteedPost(endpointId, wallPost, attempts + 1)
- })
- });
- }
- function guaranteedPost(endpointId, wallPost, attempts){
- var attempts = attempts || 0
- return graph.postAsync(endpointId + '/feed', wallPost)
- .then(function(response){
- return response
- })
- .catch(function(error){
- if(error.message != errorMessage){
- return Promise.reject(error.message)
- }
- console.log('Retry attempt #: ' + attempts)
- else if(attempts == 5){ //BLOWS UP
- return Promise.reject('Too many errors')
- }
- // console.log(error)
- return Promise.delay(5000).then(function(){
- return guaranteedPost(endpointId, wallPost, attempts + 1)
- })
- });
- }
- else if(attempts == 5){
- ^^^^
- SyntaxError: Unexpected token else
- console.log('Retry attempt #: ' + attempts)
- console.log('Retry attempt #: ' + attempts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement