/    Sign up×
Community /Pin to ProfileBookmark

How do I use this: [object Promise]?

I had some success to iterate through stringifyed`Object object`, but I do not understand how to get the data behind `object Promise`

https://jsfiddle.net/4qx6czw2/1/

It seems that the data is null (fetch not finished?). So I tried to use async/await. I got result, but not the desired result

“`
async function insert_sql(url, req) {
let body = get_insertbody(req)
let response = await fetch(url, body);
console.log(response);
}
“`

>

[object Response] {
> arrayBuffer: function arrayBuffer() {
> [native code]
> },
> blob: function blob() {
> [native code]
> },
> body: [object ReadableStream] { … },
> bodyUsed: false,
> clone: function clone() {
> [native code]
> },
> formData: function formData() {
> [native code]
> },
> headers: [object Headers] {
> append: function append() {
> [native code]
> },
> delete: function delete() {
> [native code]
> },
> entries: function entries() {
> [native code]
> },
> forEach: function forEach() {
> [native code]
> },
> get: function get() {
> [native code]
> },
> has: function has() {
> [native code]
> },
> keys: function keys() {
> [native code]
> },
> set: function set() {
> [native code]
> },
> values: function values() {
> [native code]
> }
> },
> json: function json() {
> [native code]
> },
> ok: true,
> redirected: false,
> status: 200,
> statusText: “”,
> text: function text() {
> [native code]
> },
> type: “cors”,
> url: “https://api3.go4webdev.org/usr/new
> }

The desired result should be:

`{“user_id”: “34”,”user_name”: “John”}`

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @sibert spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...