Skip to content

Instantly share code, notes, and snippets.

View vahideng's full-sized avatar

Vahid Davoudi vahideng

View GitHub Profile
@vahideng
vahideng / axios-catch-error.js
Created November 14, 2018 14:07 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@vahideng
vahideng / index.js
Created November 13, 2018 14:09 — forked from akexorcist/index.js
Axios post method requesting with x-www-form-urlencoded content type
const axios = require('axios')
...
const requestBody = {
name: 'Akexorcist',
age: '28',
position: 'Android Developer',
description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
awesome: true
@vahideng
vahideng / insering data
Created November 7, 2018 11:42
insert into MySql db in nodejs
module.exports = class Product {
constructor(id, title, imageUrl, description, price) {
this.id = id;
this.title = title;
this.imageUrl = imageUrl;
this.description = description;
this.price = price;
}
save() {
@vahideng
vahideng / gist:3f12fcc24a733834c49269b666802f43
Created October 27, 2018 15:08 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@vahideng
vahideng / Express.js middleware
Created October 27, 2018 13:23
Simple express middleware yo handle two routes
const express = require('express');
const app = express();
app.use('/user', (req, res, next) => {
console.log('in first Middleware');
res.send('<h1> Hello From second Page</h1>');
});
app.use('/', (req, res, next) => {
console.log('in secon middleware');
@vahideng
vahideng / app.js
Created October 26, 2018 14:52
simple node.js + Routing
const http = require('http');
const routes = require('./routes');
const server = http.createServer(routes);
server.listen(3000);