0
こんにちは、この問題は何度かは知っていますが、私はそれらをすべて見ましたが、解決策を見つけることができませんでした。私はイオンアプリを持っています。画像投稿はサーバーでそのエラーを表示します。エラー:ビューディレクトリ内のビュー "エラー"を検索できませんでした。
クライアント
ChangeTheProfilePicture() {
this.camera.getPicture(this.options).then((imageData) => {
this.imageURL = 'data:image/jpeg;base64,' + imageData;
var data = {
img: this.imageURL
}
this.http.post('http://myIpAdress:3100/api/addProfilePic', data)
.subscribe((data1: any) => {
console.log("done: ", data1);
}, err => {
console.log("photo err: ", err);
})
})}
サーバー
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-
Type,Cache-Control");
if (req.method === 'OPTIONS') {
res.statusCode = 204;
return res.end();
}
else {
return next();
}
});
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next();
});
// error handlers
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
//View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
//set static folder
app.use(express.static(path.join(__dirname, 'client')));
私は、サーバー側がエラーを与え、その後、私の携帯電話で写真を撮る大丈夫ボタンを押して(それも行くことができませんそのpostapi/addProfilePicを得るための経路)。私のクライアント側は真実だと思うが、サーバ側の設定ビューフォルダは間違っている。
ファイルのルートは、私は考え出し
どのようなエラーが表示されますか? – hsz
エラー:ビューディレクトリのビュー "エラー"を検索できませんでした – gnncrdm