locked
Weird syntax errors and confusion from W8 blog reader tutorial

    Question

  • Hello! Im trying to make a rss reader (just for fun and learning purposes) 
    and I am follow this (http://msdn.microsoft.com/en-us/library/windows/apps/hh974582.aspx) article.
    Right now Im having some trouble running the app because I keep this error code:

    JavaScript critical error at line 64, column 16 in ms-appx://72ebff86-2ef4-42a7-b589-94d88262555a/js/data.js

    SCRIPT1002: Syntax error

    So I checked out what it was and it is this code right here:

    return return httpClient.getStringAsync(new Windows.Foundation.Uri(url)););

    I tried changing it to:

    return httpClient.getStringAsync(new Windows.Foundation.Uri(url));

    but then it says:

    Unhandled exception at line 10, column 5 in ms-appx://72ebff86-2ef4-42a7-b589-94d88262555a/js/data.js

    0x800a138f - JavaScript runtime error: Unable to get property 'HttpClient' of undefined or null reference

    On this line here:

    var httpClient = new Windows.Web.Http.HttpClient();

    I have done everything in the tutorial (even copy pasted many times). What am I doing wrong? I am also very bad at
    making sense of the errors I get, so a little help with this would be super appreciated :)


    • Edited by Emil Jensen Tuesday, March 18, 2014 5:44 PM link fix
    Tuesday, March 18, 2014 5:43 PM

Answers

  • Are you using Visual Studio 2012 and not 2013? The Windows.Web.Http.HttpClient API is available only on Windows 8.1 and not Windows 8. This means you need to be writing a Windows 8.1 targeted app in Visual Studio 2013. The API isn't be available from within Visual Studio 2012.

    • Marked as answer by Emil Jensen Tuesday, March 18, 2014 6:31 PM
    Tuesday, March 18, 2014 6:16 PM

All replies

  • Are you using Visual Studio 2012 and not 2013? The Windows.Web.Http.HttpClient API is available only on Windows 8.1 and not Windows 8. This means you need to be writing a Windows 8.1 targeted app in Visual Studio 2013. The API isn't be available from within Visual Studio 2012.

    • Marked as answer by Emil Jensen Tuesday, March 18, 2014 6:31 PM
    Tuesday, March 18, 2014 6:16 PM
  • ooh.. thank you! I was using Visual Studios 2012 for Windows 8. If all I need is to upgrade then everything is fine. 

    But is it still

    return return httpClient.getStringAsync(new Windows.Foundation.Uri(url)););

    and not

    return httpClient.getStringAsync(new Windows.Foundation.Uri(url));

    ?

    the first one looks very weird to me.

    Tuesday, March 18, 2014 6:34 PM
  • The double return is certainly a doc bug. I'll get that one logged.
    Tuesday, March 18, 2014 6:36 PM