# HttpDo return string?

**URL:** <https://discourse.processing.org/t/httpdo-return-string/22121>\
**Category:** Coding Questions\
**Created:** [June 24, 2020, 1:18am UTC](https://discourse.processing.org/t/httpdo-return-string/22121 "2020-06-24T01:18:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasaKDH](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sasaKDH](https://discourse.processing.org/u/sasaKDH)\
**Post date:** [June 24, 2020, 1:18am UTC](https://discourse.processing.org/t/httpdo-return-string/22121/1 "2020-06-24T01:18:36Z")

</div>

```auto
function click6(){
  if(dis==1){
    username = input.value();
    httpDo(
      userURL+username,
      {
        method: 'GET',
        // Other Request options, like special headers for apis
        headers: { Authorization: apikey},
        //mode: 'no-cors',
        datatype: "json"
      },
      function(res) {
        userinfo=res;
        console.log(userinfo);
        console.log(typeof userinfo);
        console.log(userinfo.level);
      }
    );
  }
}

```

This is my code to call an API and the console result is

 ![콘솔](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a75707832122a3b5653611fd6bda8ed0d81931d4.jpeg)

Why is the type of userinfo is String? not JSON?  
and whe the userinfo.level is undefined??

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 24, 2020, 8:33pm UTC](https://discourse.processing.org/t/httpdo-return-string/22121/2 "2020-06-24T20:33:35Z")

</div>

From the reference under [HttpDo](https://p5js.org/reference/#/p5/httpDo):

> Method for executing an HTTP request. If data type is not specified, p5 will try to guess based on the URL, defaulting to text.

I suggest you provide the datatype when calling the function and see if this solves your issue.

The user info level is undefined probably because you dont have a json object in the first place. As soon as you solve the first issue, this one would work off the bat.

Kf
