Results 1 to 3 of 3

Thread: Ionic - Cordova - Angular Monorepo

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,602

    Ionic - Cordova - Angular Monorepo

    I am using Ionic and Cordova in an Angular monorepo (boy is that a mouthful). The project is structured such that there are two projects, one is an Angular library named Shared whereas the other is an Ionic project named Mobile.

    Recently I had to switch from the Angular HttpClient to the Cordova @capacitor-community/http plugin. In my shared library I created a service that gets headers, chains intercepts, catches errors and submits HTTP requests using the new plugin. In my mobile project I import the service from the shared library and make a get request. I then run the following commands in my terminal to get everything ready and to open Android Studio:
    Code:
    cd ~/projects/[project name redacted]
    npm install
    ng build shared
    ionic build --project=mobile
    cd mobile
    npx cap sync
    npx cap open android
    The issue is that when I would start debugging the project I would get an error in logcat with the following message:
    Code:
    E/Capacitor: Unable to read file at path public/plugins
    I had read somewhere that the error would appear if there weren't any Cordova plugins installed for the project. A coworker took a look at it and manually added the plugin to mobile's package.json file.

    Personally, I don't feel like this is right. It works, but I feel like there should be a command we should be running in the terminal rather than manually adding the dependency. What command? I don't know. But this just fails my smell test.

    What are your thougts?
    "Code is like humor. When you have to explain it, itís bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,705

    Re: Ionic - Cordova - Angular Monorepo

    Quote Originally Posted by dday9 View Post
    I had to switch from the Angular HttpClient
    to the Cordova @capacitor-community/http plugin.
    Simple http-communication with your serverside API then...

    Quote Originally Posted by dday9 View Post
    I feel like there should be a command we should be running in the terminal rather than manually adding the dependency. What command? I don't know. But this just fails my smell test.

    What are your thougts?
    Too many "layers, upon layers, upon layers", I guess.

    http-communication (for contacting your serverside API via RPCs aka "Ajax-calls") is already built-into the WebView-Control (normal js-functionality).

    Olaf

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,602

    Re: Ionic - Cordova - Angular Monorepo

    Quote Originally Posted by Schmidt View Post
    http-communication (for contacting your serverside API via RPCs aka "Ajax-calls") is already built-into the WebView-Control (normal js-functionality).
    Correct, I'm aware. Before switching to the plugin I was using the Angular HttpClient which leverages the browser's HTTP capabilities. The issue is that the client I am working for has their own security team and is responsible for the API and web server.

    They do not want to mess with their current CORS policy and so for a work around I presented the @capacitor-community/http plugin.
    "Code is like humor. When you have to explain it, itís bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width