小编ewi*_*ard的帖子

ExpressJS - DELETE请求后的res.redirect

我一直在搜索如何执行此操作 - 我在尝试DELETE请求后重定向 - 这是我正在使用的代码没有重定向:

exports.remove = function(req, res) {
  var postId = req.params.id;
  Post.remove({ _id: postId }, function(err) {
    if (!err) {
            console.log('notification!');
            res.send(200);
    }
    else {
            console.log('error in the remove function');
            res.send(400);
    }
  });
};
Run Code Online (Sandbox Code Playgroud)

remove在删除项目(帖子)时调用.一切正常(我不得不使用res.send(200)它来挂起删除请求) - 但现在我无法重定向.如果我res.redirect('/forum')remove函数内部使用,像这样:

exports.remove = function(req, res) {
  var postId = req.params.id;
  Post.remove({ _id: postId }, function(err) {
    if (!err) {
            console.log('notification!');
            res.send(200);
    }
    else {
            console.log('error in the remove function');
            res.send(400);
    }
    res.redirect('/forum'); …
Run Code Online (Sandbox Code Playgroud)

javascript redirect request express http-delete

12
推荐指数
3
解决办法
4231
查看次数

重要的更改位置委托方法未被调用

我的所有代码都在AppDelegate.m中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

    _locationMgr = [[CLLocationManager alloc] init];
    [_locationMgr setDelegate:self];
    if([_locationMgr respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)])
        [_locationMgr setAllowsBackgroundLocationUpdates:YES];
    CLAuthorizationStatus authorizationStatus= [CLLocationManager authorizationStatus];

    if([launchOptions valueForKey:UIApplicationLaunchOptionsLocationKey] != nil) {
        NSLog(@"relaunching because of significant location change - restarting SLC");
        [_locationMgr startMonitoringSignificantLocationChanges];
    }
    else
    {
        if (authorizationStatus == kCLAuthorizationStatusAuthorizedAlways) {
            NSLog(@"launching with authorization to always use location - starting SLC");
            [_locationMgr startMonitoringSignificantLocationChanges];
        }
        else
        {
            NSLog(@"launching with no authorization to always use location - requesting authorization");
            if([_locationMgr respondsToSelector:@selector(requestAlwaysAuthorization)])
                [_locationMgr …
Run Code Online (Sandbox Code Playgroud)

delegates background properties objective-c ios

7
推荐指数
1
解决办法
979
查看次数

离子无限涡旋很少发射

我正在努力ionInfiniteScroll工作 - 我已经让它在我的应用程序中的其他几个地方工作,而且这个页面实际上几乎与另一个工作正常的页面相同.当我向下滚动时没有任何反应,没有加载图形.我的doInfinite方法内部有一个控制台消息,它永远不会执行...所以doInfinite代码永远不会执行.我想也许html结构有问题,因为该方法没有执行:

<ion-content no-padding>
  <div (swipeLeft)="swipeLeft()" (swipeRight)="toFull()"> <!--(swipeRight)="toProfile()"-->

    ...

   <div class ='weeklydeals contentone' #weeklydeals [@moveList]='moveState'>
   <ion-list class="marginstatus" no-padding>
     <ion-item *ngFor="let a of promotions" no-padding>
      <div class="feedtoptextcontainer">
        <!--<div class="imageparent">
          <img class="postprofilepic" src="{{a.url}}">
        </div>-->
        <div class="usernamecontainer">
          <h4 class="postusername">@{{a.username}}</h4><br>
        </div>
        <h3 class="promotitle">{{a.title}}</h3>
        <div class="desccontainer">
          <h4 class="deal">{{a.caption}}</h4>
        </div>
      </div>
      <!--<img class="imagepost" src="{{i}}">-->
     </ion-item>
   </ion-list>
   <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
    <ion-infinite-scroll-content
      loadingSpinner="bubbles"
      loadingText="Loading more data...">
    </ion-infinite-scroll-content>
   </ion-infinite-scroll>
  </div>

  ...

  <ion-item class="noavail" #noavail no-padding no-lines>NO RESULTS</ion-item>
</div>
Run Code Online (Sandbox Code Playgroud)

doInfinite方法代码:

doInfinite(infiniteScroll) {
    console.log("in doinfinite promotionsssssss");
    setTimeout(() …
Run Code Online (Sandbox Code Playgroud)

html infinite-scroll typescript ionic2 angular

7
推荐指数
1
解决办法
441
查看次数

离子3压缩图像

我一直试图用Ionic 3压缩图像客户端2天.我试过了:

ng2-img-max- 使用blue-imp-canvas-to-blob canvas.toBlob()方法时抛出错误(依赖性ng2-img-max).它只告诉我错误发生在哪一行.我想我已经读过,创造一个HTMLCanvasElement离子是不可能的 - 与此有关webworkers.

Ahdin - JS library JIC - JS library TinyJPG - npm module

这些都抛出了各种错误,在研究它们之后我确定了它,因为库/模块与Ionic 3不兼容.我认为很多时候它是一个问题HTMLCanvasElement.

我在这个问题中尝试了这个建议- 但改变quality变量并没有改变图像的大小.

有没有人使用Ionic 3成功压缩客户端图像?你是怎么做到的?

javascript compression image typescript ionic-framework

6
推荐指数
1
解决办法
4424
查看次数

护照 js req.user 在 req.login 后不可用

我正在尝试正确设置我的护照会话。我已经到了这样的地步:在用户注册后 - 我执行req.login(),然后我收到一条控制台消息,console.log(req.user). 它返回:

{ email: 'xxxx', password: 'xxxx', id: 0 }

因此,似乎在创建用户后就req.user可用了。但是,当用户登录时,我有以下路线:

app.post('/login', passport.authenticate('local-login', { failureRedirect: '/login'}),
      function(req, res) {
         console.log(req.user);
         res.redirect('/users');
      }
);
Run Code Online (Sandbox Code Playgroud)

该控制台消息(来自调用后)返回:

{ id: null,
  email: 'xxxxx',
  password: 'xxxxx' }
Run Code Online (Sandbox Code Playgroud)

正如您所看到的 - 登录后 - 它重定向到/users- 这是我的获取请求:

app.get('/users', function(req, res){
  console.log(req.user);
  res.render('partials/profile.html');
});
Run Code Online (Sandbox Code Playgroud)

该控制台消息返回undefined- 所以req.user没有被传递。此外,如果我检查会话,console.log(req.session)我会得到:

{ cookie: 
   { path: '/',
     _expires: null,
     originalMaxAge: null,
     httpOnly: true,
     secure: true },
  passport: {} }
Run Code Online (Sandbox Code Playgroud)

所以你可以看到 …

javascript cookies session node.js express

5
推荐指数
1
解决办法
6084
查看次数

在iOS上滑动期间的离子渲染问题

在下面的视频中,向右滑动即将发生.在标题部分,工具栏All/Classes/Products滞后于背景图像的消失(是否有一种方法可以使背景图像跟随滑动?)黄色加号也会移动一遍40px,然后在滑动后面消失/消失其余头部消失了.

我的ion-headerHTML看起来像这样:

<ion-header #ionheader (touchstart)="swipe($event, 'start')" (touchend)="swipe($event, 'end')"> <!--[@slideDown]="downState"-->
  <ion-toolbar #clickme class="itemadspace" [@slideDown]="downState" no-padding> <!--[@slideDown]="downState"-->
    <!--<ion-item class="ad" no-padding no-lines>-->
    <div class="stylistview">
      <button class="stylistviewbutton" (tap)='switchView()' ion-button color="secondary">User View</button>
    </div>

    <!--</ion-item>-->
  </ion-toolbar>

  <div (tap)="loadPost()" class='pluscontainer' [@plusSlide]="downState">
    <ion-icon class='plussy' name="add"></ion-icon>
  </div>

  <div class="clickme" (tap)="toolClicked($event)">
    <ion-navbar  color="black" [@toolSlide]="toolbarState" id="iontoolbar"> <!--[@toolSlide]="toolbarState"-->
      <ion-icon class='custom-icon' name="play"></ion-icon>
      <button class="all toolbarstyle" #allF ion-button color="black" (tap)="all()">All</button>
      <button class="classes toolbarstyle" #classesFeed ion-button color="black" (tap)="products()">Classes</button>
      <button class="products toolbarstyle" #productsFeed ion-button color="black" (tap)="classes()">Products</button>
    </ion-navbar>
  </div>
</ion-header>
Run Code Online (Sandbox Code Playgroud)

CSS: …

html css swipe ios ionic-framework

5
推荐指数
1
解决办法
652
查看次数

Firebase函数执行和订阅列表,由firebase函数更新

我认为firebase function更新我在该列表中的列表firebase database正在subscription被订阅该列表.从我的手机上的列表输出(在应用程序中)......以及我的控制台输出的样子(重复的方式)来看,它似乎是捕获整个列表并在每次添加时显示它.所以(我看了一下)......我相信这个等式代表了正在发生的事情:

(N(N + 1))/2

这是你如何得到从1到N的所有数字的总和.在我的情况下进行数学计算(N = 30左右),我得到大约465个条目...所以你可以看到它正在加载吨,当我只希望它加载前10个.

要显示输出的内容,请输入一个pastebin https://pastebin.com/B7yitqvD.

在输出中注意上面/前面的数组length - 1 load.您可以看到它每次都会快速返回一个包含一个条目的数组并将其添加到列表中.我对我的列表中有多少项目做了非常粗略的计算,我得到了440 ...所以大致与465号码匹配.

事件链从一个页面开始,该页面不是带有此函数的列表的页面 - 它启动了firebase functions侧面的排序:

let a = this.http.get('https://us-central1-mane-4152c.cloudfunctions.net/sortDistance?text='+resp.coords.latitude+':'+resp.coords.longitude+':'+this.username);  
this.subscription6 = a.subscribe(res => {
console.log(res + "response from firesbase functions");
    loading.dismiss();
}, err => {
    console.log(JSON.stringify(err))
    loading.dismiss();
})
Run Code Online (Sandbox Code Playgroud)

这是页面上的功能list,我认为由于某种原因捕获整个排序.firebase function我认为订阅正在重复进行.

loadDistances() {
    //return new Promise((resolve, reject) => {
      let cacheKey = "distances"
      let arr = [];
      let mapped;
      console.log("IN LOADDISTANCES …
Run Code Online (Sandbox Code Playgroud)

javascript firebase ionic-framework firebase-realtime-database google-cloud-functions

5
推荐指数
1
解决办法
177
查看次数

在sceneView.session.setWorldOrigin转换之后,ARKit节点消失

我有一些代码,包含用于获取标题的委托方法和转换.我取标题并将其转换为弧度并使用角度围绕y轴旋转:

    ?                             ?
Y = |  cos(ry)    0   sin(ry)   0 |
    |  0          1   0         0 |
    |  -sin(ry)   0   cos(ry)   0 |
    |  0          0   0         1 |
    ?                             ?
Run Code Online (Sandbox Code Playgroud)

SCNMatrix4的前两列是什么?

码:

func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
        print("received heading: \(String(describing: newHeading))")
        self.currentHeading = newHeading
        print("\(Float(currentHeading.trueHeading)) or for magneticHeading: \(currentHeading.magneticHeading)")
        let headingInRadians = degreesToRadians(deg: Float(currentHeading.trueHeading))
        print("\(headingInRadians) -------- headingInRadians")

        var m = matrix_float4x4()
        m.columns.3 = [0.0, 0.0, 0.0, 1.0]
        m.columns.2 = [sin(headingInRadians), 0.0, cos(headingInRadians), 0.0]
        m.columns.1 = [0.0, …
Run Code Online (Sandbox Code Playgroud)

location transform matrix ios swift

5
推荐指数
1
解决办法
795
查看次数

firebase 功能 - `firebase deploy` - 该服务当前不可用

我正在尝试跑步firebase deploy但我得到:

\n
=== Deploying to ...\n\ni  deploying functions\ni  functions: ensuring necessary APIs are enabled...\n\xe2\x9c\x94  functions: all necessary APIs are enabled\ni  functions: preparing functions directory for uploading...\ni  functions: packaged functions (49.59 KB) for uploading\n\xe2\x9c\x94  functions: functions folder uploaded successfully\ni  functions: updating Node.js 6 function sendMessageNotification(us-central1)...\n\xe2\x9a\xa0  functions: failed to update function sendMessageNotification\nHTTP Error: 503, The service is currently unavailable.\n\n\nFunctions deploy had errors. To continue deploying other features (such as database), run:\n    firebase deploy --except functions\n\nError: Functions did not deploy …
Run Code Online (Sandbox Code Playgroud)

command-line undefined firebase google-cloud-platform google-cloud-functions

5
推荐指数
1
解决办法
4573
查看次数

React Native - StackActions.reset 什么都不做

我有这个函数,当一个<TouchableWithoutFeedback>区域被按下时会被执行:

navigateToRentable = () => {
    console.log('in navigateToRentable');

    this.props
     .navigation
     .dispatch(StackActions.reset({
       index: 0,
       actions: [
         NavigationActions.navigate({
           routeName: 'Rent',
           actions: [
              NavigationActions.navigate({
               routeName: 'Rentable',
             }),
           ]
         }),
       ],
     }))
}
Run Code Online (Sandbox Code Playgroud)

in navigateToRentable在控制台中看到,所以我知道该方法正在触发,但没有其他任何反应 - 控制台中没有其他输出。

这是我的导航结构:

CameraNavigator.js

import React from 'react';
import { StyleSheet, Text, View, Alert, Permissions, Linking, TouchableOpacity, Platform, ImageStore, Dimensions } from 'react-native';
import { createStackNavigator } from 'react-navigation';

import RentScreenNavigator from './RentScreenNavigator';
import RentScreen from '../pages/RentScreen';
import CameraScreen from '../pages/CameraScreen';
import RentableScreen from '../pages/RentableScreen'; …
Run Code Online (Sandbox Code Playgroud)

navigation components react-native react-navigation stack-navigator

4
推荐指数
1
解决办法
5442
查看次数