Working on an API that returns information my db has regarding an address The API url:
/api/allinfo?street_number=&street_name=&state=&zipcode=
Problem is this will only return a row if the spelling EXACTLY matches the spelling in my DB. How do I handle the event they misspell the street_name or give the wrong street_number for example, that it will return the CLOSEST match
I currently have
// Provide the user all the information in the GNAF dataset pertaining to
the given address.
app.get("/api/allinfo", function (req, res) {
sql.connect(dbConfig, function (err) {
const request = new sql.Request();
query = `SELECT *FROM Addresses
WHERE zipcode= @zipcode AND street_name
= @street_name AND state_abbreviation = @state_abbreviation
AND street_number = @street_number`;
request.query(query, (err, result) => {
res.send(result);
sql.close();
})
});
});
via user7983422
No comments:
Post a Comment