Nativescript: Bug: Response with status: 200 for URL: null (tns-core-modules 2.5.2)

Created on 1 Apr 2017  路  5Comments  路  Source: NativeScript/NativeScript

Hi,
I'm experiencing a bug with the new 2.5.2 tns-core-modules (Android), when I try to do an HTTP-request. It fails with an "error" (but 200 actually means success?):
Response with status: 200 for URL: null

However, I can't retrieve any data with the new modules. No other errors.
Other dependencies remained the same ("@angular/http": "2.1.2" etc.)

I had to downgrade the tns-core-modules to 2.4.3. With this version, everything works fine...

I'm using the same technique to GET-Request as shown here:
https://github.com/NativeScript/nativescript-sdk-examples-ng/blob/master/app/http/http-get/http-get.services.ts#L17

These are the dependencies (package.json) with the working version:
https://github.com/Taremeh/apphovenAlpha/blob/master/apphovenAlpha/package.json

Btw:
I also can not use the new Typescript version 2.2.2 (which got updated with Nativescript 2.5):

Found peer TypeScript 2.2.2
node_modules/tns-core-modules/declarations.d.ts(3,15): error TS2300: Duplicate identifier 'Request'.

and much more duplicates
... 

So I downgraded Typescript back to 2.1.6 and the app works again.
I also found this issue here (There seems to be coming a permanent fix with {N} 3.0?):
https://discourse.nativescript.org/t/app-wont-build-after-updating-to-2-5-1/646/4
(https://github.com/NativeScript/nativescript-dev-typescript/issues/19#event-963216101)

Whatsoever, I'd really love to upgrade and update to the newer Nativescript versions. Therefore, I'll post everything needed, to reproduce this bug.

android question

Most helpful comment

@Taremeh indeed nativeScript 3.0 will fix all of the posted issues plus it will introduce some great performance optimizations along with some breaking changes - stay in touch and expect the next official release pretty soon.
As for the TypeScript version: as TS introduced some breaking changes in TS v.2.2.X we've made all versions of NativeScript before 2.5.x compatible with TSv2.1.x.
TypeScript versions 2.2.x will be compatible with NativeScript 3.x.x.

All 5 comments

_Regarding HTTP issue_
@Taremeh we will need more info to investigate your issue. Indeed status 200 means that you have succeeded in connecting to the server. What is the full response received from your server? Is your server using SSLor are you trying to connect to localhost - similar problems were discussed here

Also the map in our example works fine for httpbin.org but you might need to goo deep for your server (again we need the full response from the server to know exactly how to parse the result)
e.g.

.map(result => result.json().data)

I have also created test application using 2.5.2 CLI and modules 2.5.2 and all the angular dependencies with versions from the default template and it works as expected/ Here you can find the test application to compare with your own.

If you 褋褌懈谢谢 encounter this behavior please post a sample project that can reproduce the case (with server URL and all requirements needed)

_Regarding TypeScript issue_
There are some changes introduced in TypeScript 2.2.x and at the current state NativeScript 2.5.x and prior are working with TypeScript .2.1.x and below.
The support for TypeScript 2.2.x and above will be supported in our next release (3.0.0) where the support for TS 2.1.x and below will not be supported.

@NickIliev Thx for your fast answer.
I use SSL / HTTPS. Today I updated back to the new 2.5.2 tns-core-modules: And I really don't know why, but it worked!

However other things start breaking:
https://github.com/NativeScript/NativeScript/issues/3625

A little disappointed 馃槥
I'll have to stay with tns-core-modules 2.4.3, although there are other issues, which are fixed with the new 2.5.2 (https://github.com/NativeScript/NativeScript/issues/3218) or the tns-core-modules@next 2.6 (https://github.com/NativeScript/NativeScript/issues/3574).

However, 2.6 doesn't work because of TypeScript incompatibility:
Not with Typescript 2.2:

Found peer TypeScript 2.2.2
app/shared/firebase/login.service.ts(59,12): error TS2693: 'Promise' only refers to a type, but is being used as a value here.

node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.

node_modules/@angular/compiler/src/compile_metadata.d.ts(347,20): error TS2304: Cannot find name 'Set'.

node_modules/@angular/compiler/src/compile_metadata.d.ts(348,15): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/offline_compiler.d.ts(19,32): error TS2304: Cannot find name 'Map'.

node_modules/@angular/compiler/src/output/output_ast.d.ts(424,63): error TS2304: Cannot find name 'Set'.

node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(28,16): error TS2304: Cannot find name 'Map'.

node_modules/@angular/core/src/di/reflective_provider.d.ts(88,123): error TS2304: Cannot find name 'Map'.

node_modules/@angular/core/src/di/reflective_provider.d.ts(88,165): error TS2304: Cannot find name 'Map'.

... AND MORE ...

and even with Typescript 2.1.6 build errors:

Found peer TypeScript 2.1.6
app/shared/firebase/login.service.ts(59,12): error TS2304: Cannot find name 'Promise'.

app/shared/firebase/piece.service.ts(14,90): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.

node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/compiler/src/compile_metadata.d.ts(347,20): error TS2304: Cannot find name 'Set'.

node_modules/@angular/compiler/src/compile_metadata.d.ts(348,15): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/directive_normalizer.d.ts(19,100): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/compiler/src/directive_normalizer.d.ts(21,74): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/compiler/src/offline_compiler.d.ts(19,32): error TS2304: Cannot find name 'Map'.

node_modules/@angular/compiler/src/offline_compiler.d.ts(43,9): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/compiler/src/output/output_ast.d.ts(424,63): error TS2304: Cannot find name 'Set'.

... AND MORE ...

Bit of a mess right now 馃槩
Hope this will be fixed with Nativescript 3.0?

@Taremeh indeed nativeScript 3.0 will fix all of the posted issues plus it will introduce some great performance optimizations along with some breaking changes - stay in touch and expect the next official release pretty soon.
As for the TypeScript version: as TS introduced some breaking changes in TS v.2.2.X we've made all versions of NativeScript before 2.5.x compatible with TSv2.1.x.
TypeScript versions 2.2.x will be compatible with NativeScript 3.x.x.

I'm still getting this issue. Using...
import { Http, Headers, Response } from "@angular/http";
...

return this.http.post(
      Config.apiUrl + "api/users/register",
      {
        email: user.email,
        password: user.password
      },
      { headers: this.getCommonHeaders() }
    )

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

valentinstoychev picture valentinstoychev  路  3Comments

Leo-lay picture Leo-lay  路  3Comments

tsonevn picture tsonevn  路  3Comments

OscarLopezArnaiz picture OscarLopezArnaiz  路  3Comments

NickIliev picture NickIliev  路  3Comments