How to navigate with URL to a page with query parameter in router.js - router

I want to be able to find a way to navigate to a page with parameter in the url for example,
Suppose if I put following like on the browser localhost:8000/?root=profiledetails&id=QQWWES Then I should be able to navigate to page configured with profiledetails in the router and also I should be able to retrieve the query parameter id QQWWES which I need to retrieve data from server.
Can anyone please help me figure this out. Appreciate your help.

You can use the router store and retrieve methods for this.
In your source page store data using store method.
router.store( routerData ); //Router is an instance of router and routerData is
//an object with required data
Then in your target page get the data using retrieve method.
var routerData = router.retrieve();

Related

how to pass http api data to anther page?

I was building a demo application for a store (not a specific one) and I got the data from an online JSON file through http requests, is it possible to pass the data to another file?
I tried to pass the data using an object from the where I extracted the data and using sharedPreferences too expecting to pass the data to the other screen and display it, but the actual output was nothing.
you can share data from one page to another page using arguments property of push method
Navigator.of(context).pushNamed("routeName",arguments: data);
to extract this data in the second page use this
ModalRoute.of(context)!.settings.arguments;

Redirect URL using Firebase Dynamic / Deep Links is losing query parameters

In my Flutter (Android/iOS) app I am using Firebase Dynamic Links for Patreon.com OAuth2 apis.
My dynamic link is https://myappname.page.link/patreon
The deep link is https://myappname.net/patreon
Patreon is using the https://myappname.page.link/patreon as a redirect_url , and is supposed to append some parameters to it, so it looks like
https://myappname.net/patreon?code=xxx
However, all I receive inside my app is the naked url https://myappname.net/patreon
There are no parameters attached to it.
So how can I tell Firebase to preserve the query parameters Patreon is attaching to the redirect_url?
As an alternate question, is there a better way to listen for incoming response inside of a Flutter app, without the use of Dynamic Links?
You loose all parameters by using that.
If you're relying on Patreon to send back that parameter I'd suggest to generate a small proxy where you can redirect your calls to the dynamic link by generating it on the fly.
So:
Patreon shares www.myhost.com/supah-link?p1=aaa&p2=bbb
Your micro-service which runs on www.myhost.com/supah-link receives the call
You generate a dynamic link like the following:
https://example.page.link/?link=https://www.example.com/someresource&apn=com.example.android&amv=3&ibi=com.example.ios&isi=1234567&ius=exampleapp&p1=aaa&p2=bbb
NOTE: Pay attention to the &p1=aaa&p2=bbb parameters added
Return a 302 and redirect to your newly generated link
Based on how you configure it from the console this link can redirect to the store or your app, in your app you can listen for the link as follows:
FirebaseDynamicLinks.instance.onLink(
onSuccess: (dynamicLink) async => handleDeepLink(dynamicLink?.link),
);
In handleDeepLink you can parse your custom query parameters.
NOTE: The URL parameter you pass via the dynamic link HAS TO BE ENCODED! Which means your link will look more like this:
https://example.page.link/?link=https%3A%2F%2Fwww.example.com%2Fsomeresource%26apn%3Dcom.example.android%26amv%3D3%26ibi%3Dcom.example.ios%26isi%3D1234567%26ius%3Dexampleapp%26p1%3Daaa%26p2%3Dbbb

Get Firebase Dynamic Link Data from String Input url Flutter

Dynamic links work great for 98% of our users. However, there are still a group of users which have difficulty with them or do not know how to use them.
I want to add a feature which would let users paste their link into the app, and then we extract the data from the link and handle it normally. This will also serve as a backup for when the links are down or misbehaving. It will also allow our customer service team to get data from a link when customers share them with us.
The problem is, there doesn't seem to be a way to manually pass in a dynamic link to retrieve the dynamic data.
Does anyone know how this can be achieved?
Here is my attempt at your question.
I am assuming what you mean by the dynamic data is the underlying deeplink along with the parameters associated with the deeplink.
void dynamicLinkToDeepLink(String dynamicLinkString) async {
final details = await FirebaseDynamicLinks.instance.getDynamicLink(Uri.parse(dynamicLinkString));
// your deep link can be accessed as follows
details!.link;
}
You have to safeguard the above code as you see fits when you use it. You will have to wrap FirebaseDynamicLinks.instance..... with a try catch block and you will also have to check if the value of the returned link is not null before acccessing details!.link

Laravel HTML form on multiple pages

How to make a form across multiple pages in Laravel like here
http://www.html-form-guide.com/php-form/php-order-form.html
I have a lot of input fields and i can't find any info on Laravel multiple pages forms. If someone has any good website where to read about it and to see how it is done?
Any help is appreciated.
You can achieve through session of laravel, you can set your values with key and value:
public function step1(Request $request)
{
$request->session()->put('key', 'value');
}
for further information see this link
Other way is make in your client side, with localStorage is cleaner for me, you can use Single Page Aplication and send the data when you're at the final step.
localStorage works seemed to PHP session, check out this link :
you can set the item thought steps, like this:
localStorage.setItem("key", "value");
and retrieve the information like this:
localStorage.getItem("key");
The Single Page application lets you render diferent pages in a route and it's not neccesary to reload the page, you can check out Angular or Ember.js Framework.
If you are looking to do this on server side and not with javascript framework here is what you can approach.
You can make use of Laravel session to store intermediate data between the pages and then pull data out of session to insert into database at the final step.
Detailed Tutorial
https://www.5balloons.info/multi-page-step-form-in-laravel-with-validation/

MVC 2.0 Post Form to action instead of redirect to action

I am using T4MVC to redirect to another action return RedirectToAction(MVC.MyController.MyAction());.
In result it is doing get request.
Is there any way to make post request from controller. I want to keep all the same but only make post instead get. I cant find any methods for that. I found one post helper here http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx but i cant pass any values i need using this post helper. I was trying to pass values through TempData but they are not coming when i using this helper. May be some one have any ideas?
The reason i want to do this because when user come from one controller to another and then if user click update or just click enter in browser address bar, page will break.
Should i use session for that reason?
A RedirectToAction will always perform a GET, never a POST (it returns a HTTP 302 to the browser, which will then issue a GET request).
To persist data across the redirect, if it is data that can be easily represented as a string and stored in the query string, then you can just add it to the route values of the redirect.
e.g.
return RedirectToAction("Search", new { searchString = "whatever" });
If it is a complex type, then you will need to store it in TempData. A number of other questions on StackOverflow (such as this one) give details on how.
If repeatedly storing to and reading from TempData across your application offends your code-sense, then you can encapsulate this by using the PassParametersDuringRedirect attribute and generic RedirectToAction available in the MvcContrib project. Some details on this technique are available here.
only way of doing post is by having a form and doing submit on that form, either with a submit button or with javascript, any info you want passed to that action must be in that form and you will find everything posted in FormCollection(hope I spelled it right).