[DOCS-12351] Stitch Basic Blog tutorial uses incorrect function Created: 11/Jan/19  Updated: 29/Oct/23  Resolved: 11/Jan/19

Status: Closed
Project: Documentation
Component/s: Stitch
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Lauren Schaefer (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 5 years, 4 weeks, 5 days ago

 Description   

Description

We need to update the blog html file to point to the latest JS SDK 

blog html

https://github.com/mongodb/stitch-examples/blob/master/basic-blog/blog.html

Latest JS SDK

https://s3.amazonaws.com/stitch-sdks/js/bundles/4/stitch.js

Original Description

https://docs.mongodb.com/stitch/tutorials/build-blog/

Step 3 currently includes to toArray() function.

When I open the blog in Chrome I get the following error in my console:

TypeError: db.collection(...).find(...).toArray is not a function
at displayComments (blog.html:30)

 

When I change toArray to asArray, the code works as expected.

 

The full example at https://github.com/mongodb/stitch-examples/blob/master/basic-blog/blog.html uses asArray.

 

According to aydrian.howard: Use `asArray` for the SDK and `toArray` for Stitch functions



 Comments   
Comment by Caleb Thompson [ 11/Jan/19 ]

Fixed. Changed version number in the tutorial example to point to latest.

Comment by Lauren Schaefer (Inactive) [ 11/Jan/19 ]

After talking with Doug Kaminsky, toArray now works in latest version.  Changing the stitch sdk to 4.1.2 fixes the error.

Generated at Thu Feb 08 08:05:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.