Reputation: 139
I want to make a get request to render a page but I need to pass 2 variables to that page. How can I create a ajax request to do this without having the variables show up in my url such as var1=?var2=?.
$.ajax({
async: true,
type: 'POST',
url: '/profile',
data: {
'UID': currentUid,
'Name': user_data.displayName
},
success: function (res) {}
})
I thought of creating a post request and passing the variables that way but then how do I render the page that I want to because my Post request doesn't fetch the page
Upvotes: 0
Views: 359
Reputation: 24590
In express you should get the page using
app.post
instead of
app.get
If you do for example:
var express=require('express')
var app=express()
app.get('/profile')
Your app will not fetch the page using POST method. Only GET method. This might be your issue.
More info:
Upvotes: 2