Skip to content

API response reverts to string, despite setting as JSON #53

@rob4629

Description

@rob4629

Specifying the hippie request as JSON: hippie.json(), doesn't result in the response being JSON.

What I'm doing (example):

// Create User Example
const hippieCreateUserRequest = () => {
  const { body: { user }} = await hippie()
    .base(baseUrl)
    .auth(username, password)
    .json()
    .headers(headers)
    .post(route)
    .send(data)
    .expectStatus(201)
    .end();
}

I'm also logging out when I use the parser:

exports.json = function(data, fn) {
  var res = null;
  var err = null;

  if (data) {
    console.log("using JSON");
    try {
      res = JSON.parse(data);
      console.log(res);
    } catch (e) {
...

Which results in res being a JSON object. However, somewhere along the line, it's converted back to a string 🤷‍♂️.

My assumption here is, by specifying hippie.json(), the response should also be JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions