Skip to content

@nativescript-community/https stopped working after I moved server files to gcp lamp instance #95

@leocrawf

Description

@leocrawf

Now this gets more and more interesting. Take a look on this code block:

packae.json:
{
"name": "my app",
"main": "app/app.js",
"version": "1.0.0",
"private": true,
"dependencies": {
"@nativescript-community/drawingpad": "^4.1.0",
"@nativescript-community/https": "^4.1.13",
"@nativescript-community/perms": "^2.3.0",
"@nativescript/appavailability": "^2.0.0",
"@nativescript/background-http": "^6.0.0",
"@nativescript/core": "~8.7.2",
"@nativescript/directions": "^2.0.2",
"@nativescript/email": "^2.1.0",
"@nativescript/imagepicker": "^3.0.1",
"@nativescript/social-share": "^2.3.0",
"@nativescript/theme": "~3.0.2",
"@nstudio/nativescript-carousel": "^8.0.3",
"@nstudio/nativescript-checkbox": "^2.0.5",
"@nstudio/nativescript-loading-indicator": "^4.3.4",
"@triniwiz/nativescript-image-cache-it": "^7.4.0",
"@triniwiz/nativescript-toasty": "^4.1.3",
"moment": "^2.30.1",
"nativescript-audio": "^6.2.6",
"nativescript-feedback": "^2.0.0",
"nativescript-phone": "^3.0.3",
"nativescript-ui-dataform": "^15.2.3",
"nativescript-ui-listview": "^15.2.3",
"nativescript-ui-sidedrawer": "~15.2.0",
"rxjs": "~7.8.0",
"underscore": "^1.13.6"
},
"devDependencies": {
"@nativescript/android": "~8.7.0",
"@nativescript/webpack": "~5.0.18"
}
}

Now this gets more and more interesting. Take a look on this code block:
import { fromObject, ObservableArray, Http as http} from "@nativescript/core"; // only imported the Http here to test but it does work. getting request.content.
//import * as http from "@nativescript-community/https"; //once work but stopped now since running on a gcp lamp instance

viewModel.getBanners = function (args) {
return http
.request({
url: ${config.apiURL}/banners.php,
method: "POST",
headers: { "Content-Type": "application/json" },
body: {},
})
.then(
(response) => {
console.log("1. is this working");
const keys = Object.keys(response);
// const result = JSON.parse(response.content);
console.log("keys: ", keys);
console.log("2. is this working", response.content); // this line does not even execute when using @nativescript-community/https
},
(e) => {}
);
};

So if the NS core Http is working why don't I just go ahead and use it. It does work when I am retrieving data but when I am sending data to the server I have issues. I would to make changes to all my server scripts. My issue is what could have changed on the lamp stack that would cause @nativescript-community/https to stop working. As can be seen I am not using any special security settings like url pinning etc. Also if I go directly to the api in the browser I get results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions