WebService Problem in Creation

WebService Problem in Creation

12 JSHint Problems
×

Line
Problem
Code snippet

58
Missing semicolon. (W033)
var token = window.localStorage.getItem('service_access_token')

76
Expected an assignment or function call and instead saw an expression. (W030)
})

76
Missing semicolon. (W033)
})

7
'$' is not defined. (W117)
return $.ajax({url: url});

13
'$' is not defined. (W117)
if (params) url = url + '?' + $.param(params);

14
'$' is not defined. (W117)
return $.ajax({url: url, type: 'GET'});

47
'window' is not defined. (W117)
var db = window.localStorage;

53
'console' is not defined. (W117)
console.log(err);

58
'window' is not defined. (W117)
var token = window.localStorage.getItem('service_access_token')

61
'$' is not defined. (W117)
var urlParams = $.extend({access_token: token}, params);

62
'$' is not defined. (W117)
var completeUrl = 'https://api.example.com/call?' + $.param(urlParams);

63
'$' is not defined. (W117)

return $.ajax({

 

 

 

hi i have just started using intel xdk. it seems to be superb thing

my problem is that i cannot create simple webservice. i am using the wizard. it is giving error on automatically created files. i thought if i create it then i would be able to use wizard .please see error below. here is my js file. you can see the error log. 

 

(function (credentials, helpers) {
  var exports = {};
  
  /* Data Feed Function */
  exports.methodA1 = function (params) {
    var url = 'http://example.api/methodA1?api_key_var_name=' + credentials.apiKey;
    return $.ajax({url: url});
  };
  
  exports.methodA1User = function(params) {
    var url = 'http://example.api/methodA1/user/' + params.UserId;
    delete params.UserId;
    if (params) url = url + '?' + $.param(params);
    return $.ajax({url: url, type: 'GET'});
  };
  
  /* OAuth Functions */
  exports.methodA1Authenticate = function(params) {
    // var implicitUrl = 'https://www.exampleurl.com/auth?';
    var url = {
      codeUrl: 'https://www.exampleurl.com/auth?',
      tokenUrl: 'https://www.exampleurl.com/access_token?'
    };
    
    //parameters will vary from service to service
    /* var = implicitParams {
      client_id: credentials.apiKey,
      redirect_uri: params.redirect_uri,
      response_type: params.response_type
    } */
    var urlParams = {
      code: {
        client_id: credentials.apiKey,
        redirect_uri: params.redirect_uri,
        response_type: params.response_type
      },
      token: {
        client_secret: credentials.apiSecret,
        grant_type: 'authorization_code'
      }
    };
    
    //helper oauth functions return access token. check to see if service uses authentication code or implicit oauth
    //return helpers.oauth2Implicit(implicitUrl, implicitParams)
    return helpers.oauth2AuthCode(url, urlParams)
    .then(function(token){
      var db = window.localStorage;
      //'service_access_token' should be unique to each service so that multiple authenticated services can be used
      db.setItem('service_access_token', token);
      return token;
    })
    .fail(function(err){
      console.log(err);
    });
  };
  
  exports.authenticatedMethodA1 = function(params){
    var token = window.localStorage.getItem('service_access_token');
    if (!token) return 'Need access token before making call';
    
    var urlParams = $.extend({access_token: token}, params);
    var completeUrl = 'https://api.example.com/call?' +  $.param(urlParams);
    return $.ajax({
      url: completeUrl,
      type: 'GET',
      dataType: 'json'})
    .then(function(response){
      return response;
    })
    .fail(function(err){
      return err.responseText;
    });
  };
  
  return exports;
})

 

12 JSHint Problems
×

Line
Problem
Code snippet

58
Missing semicolon. (W033)
var token = window.localStorage.getItem('service_access_token')

76
Expected an assignment or function call and instead saw an expression. (W030)
})

76
Missing semicolon. (W033)
})

7
'$' is not defined. (W117)
return $.ajax({url: url});

13
'$' is not defined. (W117)
if (params) url = url + '?' + $.param(params);

14
'$' is not defined. (W117)
return $.ajax({url: url, type: 'GET'});

47
'window' is not defined. (W117)
var db = window.localStorage;

53
'console' is not defined. (W117)
console.log(err);

58
'window' is not defined. (W117)
var token = window.localStorage.getItem('service_access_token')

61
'$' is not defined. (W117)
var urlParams = $.extend({access_token: token}, params);

62
'$' is not defined. (W117)
var completeUrl = 'https://api.example.com/call?' + $.param(urlParams);

63
'$' is not defined. (W117)
return $.ajax({

 

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

 

thanks for the reply

yes i have seen it . if you move the slider to 25 minutes and 51 seconds then you would notice that she was saying to cover it in another topic if ppl are interested in creating own service. she had covered the built in added webservices whcih are pretty easy to use but creating own service she touched but not covered. like i followed the same but even i didnt touch the code the editor is giving above errors. like i just created a service and then from the code it added the errors have been caught. my application is using ionic framework. and i am coming from ios background.

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today