Skip to content

Instantly share code, notes, and snippets.

@converge
Created October 30, 2018 14:53
Show Gist options
  • Save converge/41c89bc89b07b425ad627059eec4398f to your computer and use it in GitHub Desktop.
Save converge/41c89bc89b07b425ad627059eec4398f to your computer and use it in GitHub Desktop.
#
# axios
#
import axios from 'axios'
const api = axios.create({
baseURL: 'http://localhost:3000'
})
export default api;
#
# express
#
app.get("/get_username_by_username", function(req, res) {
try {
const stmt = db.prepare(
"SELECT id, username, password FROM ig_account WHERE username = ?"
);
const row = stmt.get(req.query.username);
return res.status(200).json({
data: row
});
} catch (err) {
return res.status(500).send("Something went wrong");
}
});
#
# chamada
#
const response = await api.get("/get_username_by_username", {
params: {
username: this.props.active_ig_account
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment