-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathindex.js
38 lines (35 loc) · 785 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// load the mysql library
var mysql = require('mysql');
// create a connection to our Cloud9 server
var connection = mysql.createConnection({
host : 'localhost',
user : 'ziad_saab', // CHANGE THIS :)
password : '',
database: 'reddit'
});
// load our API and pass it the connection
var reddit = require('./reddit');
var redditAPI = reddit(connection);
// It's request time!
redditAPI.createUser({
username: 'hello23',
password: 'xxx'
}, function(err, user) {
if (err) {
console.log(err);
}
else {
redditAPI.createPost({
title: 'hi reddit!',
url: 'https://www.reddit.com',
userId: user.id
}, function(err, post) {
if (err) {
console.log(err);
}
else {
console.log(post);
}
});
}
});