I’m a newbie to PWA and wanted to make a simple login page.
I created a simple page with email and password inputs and a login button.
Now I want the button to call my backend login API (webservice).
I tried creating a service where the code should go but I got a message:
[ERROR] Sorry! ionic g can only be run in an Ionic project directory.
I looked for some info about it but got lost in the way. Where can I have an article or any other helpful information about adding http requests to a PWA project?
There’s no requirement to use Ionic’s generators for anything. I don’t. You can write services just like they are described in Angular’s Tour of Heroes.
Same comment about Angular’s generators; you don’t have to use them (and I don’t). Might it make more sense if that error message said “cd inside your project directory; you’re currently outside it”?
If you don’t get any better answers, mine is “create a new file and write it from scratch”. It’s not very much typing, and will get your eyes, mind, and fingers accustomed to what things should look like, which will help you spot anomalies quicker.
No, a PWA can be created with any js tool…Ionic, Angular, Stencil or plain js.
If you are creating your app with Ionic, Angular or Stencil and you want to use their shortcuts, then you need to stick with their conventions for generating services etc and use “ionic g” or “ng g” etc as appropriate.
Or, as @rapropos suggests, just create the required file and use the appropriate js code, you don’t need any other tools.
I suggest you do a course on PWA, there are several introductory videos on youtube…