How to use the getStatusText function from http-status-codes

Find comprehensive JavaScript http-status-codes.getStatusText code examples handpicked from public code repositorys.

26
27
28
29
30
31
32
33
34
35
} = req.body;

if (!email || !name) {
    return res.status(BAD_REQUEST).send({
        status: FAIL,
        message: HttpStatus.getStatusText(BAD_REQUEST),
    });
}

const newUser = new User({
fork icon0
star icon3
watch icon5

+ 27 other calls in file

8
9
10
11
12
13
14
15
16
17
  this.connector = connector;
}

async getManufacturers({ name }, { me }, info) {
  if (!me) {
    throw new ApolloError(invalidToken, getStatusText(UNAUTHORIZED));
  }
  const query = `FOR m IN FULLTEXT(manufacturers, 'name', '${name}') LIMIT 5 RETURN {'id':m._key,'name':m.name}`;
  const cursor = await this.connector.Query(query);
  return cursor.all();
fork icon0
star icon1
watch icon2

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
30
        .send('ok');

response
        .status(HttpStatus.INTERNAL_SERVER_ERROR)
        .send({
                error: HttpStatus.getStatusText(HttpStatus.INTERNAL_SERVER_ERROR)
        });
```

## Codes
fork icon103
star icon0
watch icon2

+ 11 other calls in file

36
37
38
39
40
41
42
43
44
45

function error(status, err) {
        return {
                status: status,
                data: {
                        statusError: statusCodes.getStatusText(status),
                        err: err
                }
        };
}
fork icon3
star icon0
watch icon7

+ 15 other calls in file

0
1
2
3
4
5
6
7
8
9
const HttpStatus = require('http-status-codes');

class ApiError {
  constructor(statusCode, message) {
    this.statusCode = statusCode;
    this.message = message || HttpStatus.getStatusText(statusCode);
  }
}

class ServerError extends ApiError {
fork icon0
star icon0
watch icon2

+ 15 other calls in file