curl testing with javascript
Cannot GET /search-result/ac
i get this error when i do he curl testing
enter image description here
how do i resolve this as this is all my code
const resultHTML = `
<div class="col-sm-12 col-md-6 col-lg-4 p-b-50">
<!-- Block2 -->
<div class="block2">
<div class="block2-img wrap-pic-w of-hidden pos-relative block2-labelnew" id="itemLabel">
<img alt="IMG-PRODUCT" id="itemImage">
</div>
<div class="block2-txt p-t-20">
<a href="javascript:void(0);" class="block2-name dis-block s-text3 p-b-5" onclick="getItemDetails(event)">
<span id="itemId" hidden></span><span id="itemTitle"></span>
</a>
<span class="block2-price m-text6 p-r-5">
$<span id="itemPrice"></span>
</span>
</div>
</div>
</div>
`;
function getItemDetails(event)
const itemId = $(event.target)
.siblings('span')
.text();
window.location.href = '/product-detail?itemid=' + itemId;
function getSearchResult(value)
if( value !== "")
$.ajax(
method: 'GET',
url: '/search-result' ,
data:
value: value
,
success: res =>
if (res.success == 0) handle_error(res.error);
else
res.data.rows.forEach(row =>
const $itemList = $(resultHTML);
$itemList.find('#itemImage').attr('src', row.picture);
$itemList.find('#itemId').text(row.item_id);
$itemList.find('#itemTitle').text(row.title);
$itemList.find('#itemPrice').text(row.price);
if (row.sale == true)
$itemList
.find('#itemLabel')
.removeClass('block2-labelnew')
.addClass('block2-labelsale');
$('#searchresult').append($itemList);
window.sessionStorage.clear();
);
);
$(document).ready(function(e) );
and the server.js file
app.get('/search-result', async (req, res) =>
const client = await pool.connect();
let value = req.query.value;
value = striptags(value.replace(/'/g, "\'")).trim();
// console.log('final value: ' + value);
const query = `SELECT item_id, title, price, picture, sale FROM items
where title ilike '%$value%' ORDER BY item_id; `;
await client.query(query, (err, result) =>
if (err)
res.json(
success: 0,
error: err
);
else
res.json(
success: 1,
data: result
);
);
client.release();
);
is there anyone out there that would help me to get the results from the curl testing. is it because i cache the search result and afterwards deleted imediately
javascript node.js curl heroku
add a comment |
Cannot GET /search-result/ac
i get this error when i do he curl testing
enter image description here
how do i resolve this as this is all my code
const resultHTML = `
<div class="col-sm-12 col-md-6 col-lg-4 p-b-50">
<!-- Block2 -->
<div class="block2">
<div class="block2-img wrap-pic-w of-hidden pos-relative block2-labelnew" id="itemLabel">
<img alt="IMG-PRODUCT" id="itemImage">
</div>
<div class="block2-txt p-t-20">
<a href="javascript:void(0);" class="block2-name dis-block s-text3 p-b-5" onclick="getItemDetails(event)">
<span id="itemId" hidden></span><span id="itemTitle"></span>
</a>
<span class="block2-price m-text6 p-r-5">
$<span id="itemPrice"></span>
</span>
</div>
</div>
</div>
`;
function getItemDetails(event)
const itemId = $(event.target)
.siblings('span')
.text();
window.location.href = '/product-detail?itemid=' + itemId;
function getSearchResult(value)
if( value !== "")
$.ajax(
method: 'GET',
url: '/search-result' ,
data:
value: value
,
success: res =>
if (res.success == 0) handle_error(res.error);
else
res.data.rows.forEach(row =>
const $itemList = $(resultHTML);
$itemList.find('#itemImage').attr('src', row.picture);
$itemList.find('#itemId').text(row.item_id);
$itemList.find('#itemTitle').text(row.title);
$itemList.find('#itemPrice').text(row.price);
if (row.sale == true)
$itemList
.find('#itemLabel')
.removeClass('block2-labelnew')
.addClass('block2-labelsale');
$('#searchresult').append($itemList);
window.sessionStorage.clear();
);
);
$(document).ready(function(e) );
and the server.js file
app.get('/search-result', async (req, res) =>
const client = await pool.connect();
let value = req.query.value;
value = striptags(value.replace(/'/g, "\'")).trim();
// console.log('final value: ' + value);
const query = `SELECT item_id, title, price, picture, sale FROM items
where title ilike '%$value%' ORDER BY item_id; `;
await client.query(query, (err, result) =>
if (err)
res.json(
success: 0,
error: err
);
else
res.json(
success: 1,
data: result
);
);
client.release();
);
is there anyone out there that would help me to get the results from the curl testing. is it because i cache the search result and afterwards deleted imediately
javascript node.js curl heroku
1
/ac
isn't a query string element it's part of the path. Try updating your route to/search-result/:term
they access it by usingreq.params.term
– Adam H
Nov 14 '18 at 23:22
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23
add a comment |
Cannot GET /search-result/ac
i get this error when i do he curl testing
enter image description here
how do i resolve this as this is all my code
const resultHTML = `
<div class="col-sm-12 col-md-6 col-lg-4 p-b-50">
<!-- Block2 -->
<div class="block2">
<div class="block2-img wrap-pic-w of-hidden pos-relative block2-labelnew" id="itemLabel">
<img alt="IMG-PRODUCT" id="itemImage">
</div>
<div class="block2-txt p-t-20">
<a href="javascript:void(0);" class="block2-name dis-block s-text3 p-b-5" onclick="getItemDetails(event)">
<span id="itemId" hidden></span><span id="itemTitle"></span>
</a>
<span class="block2-price m-text6 p-r-5">
$<span id="itemPrice"></span>
</span>
</div>
</div>
</div>
`;
function getItemDetails(event)
const itemId = $(event.target)
.siblings('span')
.text();
window.location.href = '/product-detail?itemid=' + itemId;
function getSearchResult(value)
if( value !== "")
$.ajax(
method: 'GET',
url: '/search-result' ,
data:
value: value
,
success: res =>
if (res.success == 0) handle_error(res.error);
else
res.data.rows.forEach(row =>
const $itemList = $(resultHTML);
$itemList.find('#itemImage').attr('src', row.picture);
$itemList.find('#itemId').text(row.item_id);
$itemList.find('#itemTitle').text(row.title);
$itemList.find('#itemPrice').text(row.price);
if (row.sale == true)
$itemList
.find('#itemLabel')
.removeClass('block2-labelnew')
.addClass('block2-labelsale');
$('#searchresult').append($itemList);
window.sessionStorage.clear();
);
);
$(document).ready(function(e) );
and the server.js file
app.get('/search-result', async (req, res) =>
const client = await pool.connect();
let value = req.query.value;
value = striptags(value.replace(/'/g, "\'")).trim();
// console.log('final value: ' + value);
const query = `SELECT item_id, title, price, picture, sale FROM items
where title ilike '%$value%' ORDER BY item_id; `;
await client.query(query, (err, result) =>
if (err)
res.json(
success: 0,
error: err
);
else
res.json(
success: 1,
data: result
);
);
client.release();
);
is there anyone out there that would help me to get the results from the curl testing. is it because i cache the search result and afterwards deleted imediately
javascript node.js curl heroku
Cannot GET /search-result/ac
i get this error when i do he curl testing
enter image description here
how do i resolve this as this is all my code
const resultHTML = `
<div class="col-sm-12 col-md-6 col-lg-4 p-b-50">
<!-- Block2 -->
<div class="block2">
<div class="block2-img wrap-pic-w of-hidden pos-relative block2-labelnew" id="itemLabel">
<img alt="IMG-PRODUCT" id="itemImage">
</div>
<div class="block2-txt p-t-20">
<a href="javascript:void(0);" class="block2-name dis-block s-text3 p-b-5" onclick="getItemDetails(event)">
<span id="itemId" hidden></span><span id="itemTitle"></span>
</a>
<span class="block2-price m-text6 p-r-5">
$<span id="itemPrice"></span>
</span>
</div>
</div>
</div>
`;
function getItemDetails(event)
const itemId = $(event.target)
.siblings('span')
.text();
window.location.href = '/product-detail?itemid=' + itemId;
function getSearchResult(value)
if( value !== "")
$.ajax(
method: 'GET',
url: '/search-result' ,
data:
value: value
,
success: res =>
if (res.success == 0) handle_error(res.error);
else
res.data.rows.forEach(row =>
const $itemList = $(resultHTML);
$itemList.find('#itemImage').attr('src', row.picture);
$itemList.find('#itemId').text(row.item_id);
$itemList.find('#itemTitle').text(row.title);
$itemList.find('#itemPrice').text(row.price);
if (row.sale == true)
$itemList
.find('#itemLabel')
.removeClass('block2-labelnew')
.addClass('block2-labelsale');
$('#searchresult').append($itemList);
window.sessionStorage.clear();
);
);
$(document).ready(function(e) );
and the server.js file
app.get('/search-result', async (req, res) =>
const client = await pool.connect();
let value = req.query.value;
value = striptags(value.replace(/'/g, "\'")).trim();
// console.log('final value: ' + value);
const query = `SELECT item_id, title, price, picture, sale FROM items
where title ilike '%$value%' ORDER BY item_id; `;
await client.query(query, (err, result) =>
if (err)
res.json(
success: 0,
error: err
);
else
res.json(
success: 1,
data: result
);
);
client.release();
);
is there anyone out there that would help me to get the results from the curl testing. is it because i cache the search result and afterwards deleted imediately
javascript node.js curl heroku
javascript node.js curl heroku
asked Nov 14 '18 at 23:17
jack99jackjack99jack
62
62
1
/ac
isn't a query string element it's part of the path. Try updating your route to/search-result/:term
they access it by usingreq.params.term
– Adam H
Nov 14 '18 at 23:22
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23
add a comment |
1
/ac
isn't a query string element it's part of the path. Try updating your route to/search-result/:term
they access it by usingreq.params.term
– Adam H
Nov 14 '18 at 23:22
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23
1
1
/ac
isn't a query string element it's part of the path. Try updating your route to /search-result/:term
they access it by using req.params.term
– Adam H
Nov 14 '18 at 23:22
/ac
isn't a query string element it's part of the path. Try updating your route to /search-result/:term
they access it by using req.params.term
– Adam H
Nov 14 '18 at 23:22
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310198%2fcurl-testing-with-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310198%2fcurl-testing-with-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
/ac
isn't a query string element it's part of the path. Try updating your route to/search-result/:term
they access it by usingreq.params.term
– Adam H
Nov 14 '18 at 23:22
also look here for more info regarding routing: expressjs.com/en/guide/routing.html
– Adam H
Nov 14 '18 at 23:23