ionic-framework

Capacitor on iOS: POST request fails

懵懂的女人 提交于 2020-04-18 03:48:32
问题 I'm using Ionic (v5) + React + Capacitor to create an app for iOS and I recently got stuck with a really strange error: fetch() and axios successfully perform GET requests to the backend while POST requests are always failing. fetch() returns "cancelled" which tells me nothing but a failure meanwhile axios generates a more descriptive error: { "message": "Network Error", "name": "Error", "stack": "capacitor://localhost/static/js/8.98344607.chunk.js:2:168604\ncapacitor://localhost/static/js/8

Render JSON in html from Service [Ionic 4]

♀尐吖头ヾ 提交于 2020-04-17 22:09:41
问题 Thanks to parrycima, I created my first service. results.service.ts constructor(private httpService: HttpClient) { } async checkFunc() { this.apiurl = 'https://my.apiurl.com/'; this.httpService.get(this.apiurl).subscribe(res => { if (res) { this.items = Object.keys(res).map(function(key) { return res[key]; }); } }, (err: HttpErrorResponse) => { console.log (err.message); } ); } app.component.ts export class AppComponent { constructor( public myService: ResultsService, private httpService:

Render JSON in html from Service [Ionic 4]

跟風遠走 提交于 2020-04-17 22:06:58
问题 Thanks to parrycima, I created my first service. results.service.ts constructor(private httpService: HttpClient) { } async checkFunc() { this.apiurl = 'https://my.apiurl.com/'; this.httpService.get(this.apiurl).subscribe(res => { if (res) { this.items = Object.keys(res).map(function(key) { return res[key]; }); } }, (err: HttpErrorResponse) => { console.log (err.message); } ); } app.component.ts export class AppComponent { constructor( public myService: ResultsService, private httpService:

Ionic 2 - How to make a login post request?

為{幸葍}努か 提交于 2020-04-16 03:33:48
问题 I need to implement login in my Ionic 2 app. For now I just need to be sure that the email and the password are properly received and get back a basic response. I have successfully tested a GET request to the API and it is properly working, but I am not able to get the POST request working. I have tried two approaches: Using subscribe : Login component: submitLogin() { var email = this.loginForm.value.email.trim(); var password = this.loginForm.value.password.trim(); this.userService

Ionic 2 - How to make a login post request?

青春壹個敷衍的年華 提交于 2020-04-16 03:33:34
问题 I need to implement login in my Ionic 2 app. For now I just need to be sure that the email and the password are properly received and get back a basic response. I have successfully tested a GET request to the API and it is properly working, but I am not able to get the POST request working. I have tried two approaches: Using subscribe : Login component: submitLogin() { var email = this.loginForm.value.email.trim(); var password = this.loginForm.value.password.trim(); this.userService

Protocol Buffers in Ionic

我们两清 提交于 2020-04-16 02:35:28
问题 Attempting to use Protocol Buffers in Ionic 4 to encode & decode messages. Have tried to use protobufjs and also google-protobuf, but can't get either to work. I have downloaded the protoc and used it to generate a bunch of _pb.js files, one for each .proto file. That's fine. Focusing on the protobuf example first. Here's the example code: import { load } from "protobufjs"; // respectively "./node_modules/protobufjs" load("awesome.proto", function(err, root) { if (err) throw err; // example

Ionic + CreateJs high CPU and Memory

梦想的初衷 提交于 2020-04-14 07:00:49
问题 I have a serious problem with an increasing CPU and RAM usage in an ionic app with createjs library. The problem cause the app to crash after a while. As I am navigating between pages where each page has a new canvas, I see the RAM and CPU to dramatically increase. There is no memory leak. I have tested it with chrome developer tools. 回答1: After so so much testing, the solution was to treat each template page in ionic as a root page. So when I was navigating to a new template page I always

SyntaxError: Unexpected token C in JSON at position 0 - Ionic 2 Http GET request

青春壹個敷衍的年華 提交于 2020-04-10 17:55:01
问题 I am trying to perform a GET request and retrieve the data from the response. this.http.get('http://localhost:8888/maneappback/more-items.php').subscribe(res => { console.log(res.json()); }, (err) => { console.log(err); }); I am getting the error SyntaxError: Unexpected token C in JSON at position 0 . I am also assuming that the error is related to the request. On my server side, I have the data being sent like this (PHP): echo json_encode($array); 回答1: The message you see is that your JSON

SyntaxError: Unexpected token C in JSON at position 0 - Ionic 2 Http GET request

谁说胖子不能爱 提交于 2020-04-10 17:49:19
问题 I am trying to perform a GET request and retrieve the data from the response. this.http.get('http://localhost:8888/maneappback/more-items.php').subscribe(res => { console.log(res.json()); }, (err) => { console.log(err); }); I am getting the error SyntaxError: Unexpected token C in JSON at position 0 . I am also assuming that the error is related to the request. On my server side, I have the data being sent like this (PHP): echo json_encode($array); 回答1: The message you see is that your JSON

How to fix member Event from @ionic/angular error in Ionic 5

别等时光非礼了梦想. 提交于 2020-04-04 08:03:32
问题 I have upgraded from Ionic 4 to Ionic 5, now getting following error: ERROR in src/app/app.component.ts(4,10): error TS2305: Module '"/node_modules/@ionic/angular/ionic-angular"' has no exported member 'Events'. Following import line is causing the issue: import { Events, Platform } from '@ionic/angular'; How can I fix member Event from @ionic/angular error in Ionic 5? 回答1: Events from @ionic/angular package got removed from Ionic 5. You can see the breaking changes in Ionic5 here. As it's