小编Azz*_*ian的帖子

FaunaDB 应用程序返回 401 但凭据正常

我想尝试 FaunaDB,所以我制作了一个 NodeJS 应用程序。我按照教程制作了一个像 Twitter 这样的应用程序。但是,当我尝试访问数据库时,我收到 403 未经授权的消息。我已经检查了我的安全密钥,但仍然遇到相同的错误。任何帮助,将不胜感激。

.env 文件:

KEY=randomString
PORT=5000
Run Code Online (Sandbox Code Playgroud)

索引.js:

require("dotenv").config();
const app = require("express")();
const faunadb = require("faunadb");

const client = new faunadb.Client({
    secret: process.env.KEY,
});

const {
    Paginate,
    Get,
    Select,
    Match,
    Index,
    Create,
    Collection,
    Lambda,
    Var,
    Join,
    Ref,
} = faunadb.query;

app.listen(5000, () => console.log(`API on http://localhost:${process.env.PORT}`));

app.get("/tweet/:id", async (req, res) => {
    try {
        const doc = await client.query(
            Get(
                Ref(
                    Collection("tweets"),
                    req.params.id
                )
            )
        )
        res.send(doc);

    } catch (err) {
        res.send(err)
    }
}); …
Run Code Online (Sandbox Code Playgroud)

node.js faunadb serverless

8
推荐指数
1
解决办法
1397
查看次数

qsort 创建非特定数量的零

所以我的程序从文件中读取整数,同时跳过以 开头的行,#然后将它们存储在一个数组中并使用该qsort函数将它们排序打印出来。但是,当它们被打印时,由于某种原因,它在开始时会打印一些零,然后是排序后的数字。如果数字对是 60,我得到 21 个零,如果数字对是 103688,它打印 60151 个零。

输入文件:

#Skip
#These
#Lines
25  8
25  19
25  23
25  28
25  29
25  30
25  33
25  35
25  50
25  54
25  55
Run Code Online (Sandbox Code Playgroud)

该计划是:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>


typedef struct {
    int start;
    int end;   
} path;

int cmp(const void *a,const void *b){
    int l=((path*)a)->start;
    int r=((path*)b)->start;

    if(l>r)
        return 1;
    if(l<r)
        return -1;
    if(l==r)
        return 0;
}

int doublesize(path** array,int n){
    path* new_array=malloc(n*2*sizeof(path));
    if(new_array==NULL){
        printf("Error allocating …
Run Code Online (Sandbox Code Playgroud)

c zero qsort

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

segmentation fault (core dump) while loading a file

I am trying to create a function which loads data from a .txt file but when it runs I always get a segmentation fault(core dumped) error. The file contains an unknown number of lines while each line has a string and an integer separated by tab.The list_create function just creates a data structure. The while loop in the end deletes the data structure, I did not include the code because I am sure it does not cause the problem but …

c coredump file segmentation-fault

0
推荐指数
1
解决办法
62
查看次数

标签 统计

c ×2

coredump ×1

faunadb ×1

file ×1

node.js ×1

qsort ×1

segmentation-fault ×1

serverless ×1

zero ×1