0

I am having a web application built using JAVA spring which has API feature to read and write into database.

Now i have to develop an ionic mobile app for the same application. How to read and write data into database.

I know Firebase and other alternatives can do the job.

But i need my own API code(written for web app) to be used. Is there any way to achieve that?

I guess calling the respective API when the web application is live is achievable.

But how can i achieve that while developing(When the web app is under construction)

1 Answer 1

1

Well depending on how you set up the API this could become quite difficult.

You're saying/guessing that you can call the API when the webapplication is live. This makes me assume you've created a REST API? Or did you create a Spring MVC application?

If the webapplication is directly linked to your Spring application (f.e. going to localhost:8080/my-profile shows a page (not JSON) of your profile) then I'm not sure if you can achieve the above mentioned target.

If you get a JSON response, or are somehow able to retrieve it from the webpage, you can just simply call (in typescript:)

this.http.get('http://localhost:8080/my-profile').map(response => console.log(response.json() );

Else, you probably will have to create a basic REST API (check out Spring boot for a 5 minute setup) and provide it, either with hardcoded data or connect it with your database.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Ivaro18 for your reply. I have my API's already. I was looking for "How to call those API's while developing in my local (both web and mobile app) and while live.
From your comment i come to know that we call directly to my localhost url when the server is started. please correct me if i am wrong. My url is 127.0.0.1:8081/api/training/1. Obviously yes, when i call this i get a JSON response in return. Hence i got my answer. Thanks Ivaro18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.