这是我的代码:
github.repos.getContent({
user: "vydingding",
repo: "vydingding.github.io",
path: "_data/faculty.csv"
}, function(err, res) {
pastfile = res.sha;
response.json({ message: 'Successful! Sha: ' + res.sha});
github.repos.updateFile({
var public_spreadsheet_url='https://docs.google.com/spreadsheets/d/1Etze7fBNH3j4ss4-LPz_-khYRKnh0w34ScsqaJDvXtE/pubhtml';
var tabletop = Tabletop.init( { key: public_spreadsheet_url, callback: showInfo, simpleSheet: true } )
function showInfo(data, tabletop) {
var fields = ['Faculty Name', 'Age'];
json2csv({ data: data, fields: fields }, function(err, csv) {
if
(err) console.log(err);
data = csv;
});
data = new Buffer(data.toString('base64'));
buff = data.toString('base64');
user: "vydingding",
repo: "vydingding.github.io",
path: "_data/faculty.csv",
message: "Faculty list change",
content: buff
sha: pastfile
}}, function(err, res) {
response.json({ message: 'Update file successful!'});
});
});
它说的是:
var public_spreadsheet_url='https://docs.google.com/spreadsheets/d/1Etze7fBNH3j4ss4-LPz_-khYRKnh0w34ScsqaJDvXtE/pubhtml';
有一个意外的标识符。我试过跟踪它,我找不到意外的标识符。我该如何解决这个问题? 提前谢谢。
答案 0 :(得分:0)
前面的行无效:
github.repos.updateFile({
答案 1 :(得分:0)
这是一个明确的语法错误,可以非常轻松地 FIXED :
只需将以下部分代码放在此行github.repos.updateFile({
之上,一切都会好的。
var public_spreadsheet_url='https://docs.google.com/spreadsheets/d/1Etze7fBNH3j4ss4-LPz_-khYRKnh0w34ScsqaJDvXtE/pubhtml';
var tabletop = Tabletop.init( { key: public_spreadsheet_url, callback: showInfo, simpleSheet: true } )
function showInfo(data, tabletop) {
var fields = ['Faculty Name', 'Age'];
json2csv({ data: data, fields: fields }, function(err, csv) {
if
(err) console.log(err);
data = csv;
});
data = new Buffer(data.toString('base64'));
buff = data.toString('base64');
修改仍然存在我为您修复的语法错误,以下是您的代码的完整修复版本:
github.repos.getContent({
user: "vydingding",
repo: "vydingding.github.io",
path: "_data/faculty.csv"
}, function (err, res) {
pastfile = res.sha;
response.json({message: 'Successful! Sha: ' + res.sha});
var public_spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1Etze7fBNH3j4ss4-LPz_-khYRKnh0w34ScsqaJDvXtE/pubhtml';
var tabletop = Tabletop.init({key: public_spreadsheet_url, callback: showInfo, simpleSheet: true})
function showInfo(data, tabletop) {
var fields = ['Faculty Name', 'Age'];
json2csv({data: data, fields: fields}, function (err, csv) {
if (err)
console.log(err);
data = csv;
});
data = new Buffer(data.toString('base64'));
buff = data.toString('base64');
}
github.repos.updateFile({
user: "vydingding",
repo: "vydingding.github.io",
path: "_data/faculty.csv",
message: "Faculty list change",
content: buff
sha: pastfile
}
,
function (err, res) {
response.json({message: 'Update file successful!'});
});
});